Sha256: 723069c821a2e509ee8191cfc00b1aa433f15eabb265c26b44fa8dc28240d599
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
class Quandl::Command::Tasks::Login < Quandl::Command::Tasks::Base description "Login to quandl with username and email." options String => { method: 'Login method? ( password | token )' } def execute authenticate! reload_session! if current_user.present? info "You have successfully authenticated!" info current_user.info else error "Failed to authenticate!" end end def authenticate! return execute_password_login if options.method == 'password' execute_token_login end def execute_token_login info("Obtain your Auth Token from this page: http://www.quandl.com/users/info") token = ask("Auth Token: "){ |q| q.echo = "*" } write_auth_token(token) end def execute_password_login # request login and password login = ask("Username or Email: ") password = ask("Password: "){ |q| q.echo = "*" } # attempt to login user = Quandl::Client::User.login( login: login, password: password ) # fail on errors return error( user.human_status ) unless user.auth_token.present? # output qdf write_auth_token(user.auth_token) info "You've successfully authorized #{login}!" end def write_auth_token(token) QConfig.configuration.token = token end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quandl-0.2.22 | lib/quandl/command/tasks/login.rb |