Class: Appfront::Command::Auth
- Defined in:
- lib/appfront/command/auth.rb
Class Method Summary collapse
Class Method Details
.authenticate! ⇒ Object
62 63 64 65 |
# File 'lib/appfront/command/auth.rb', line 62 def self.authenticate! return true if authenticated? login end |
.credentials ⇒ Object
67 68 69 |
# File 'lib/appfront/command/auth.rb', line 67 def self.credentials netrc['jarvis.appfront.io'] end |
.login ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/appfront/command/auth.rb', line 4 def self.login puts "Enter your Appfront credentials." print "email: " email = ask print "password: " echo_off pass = ask_for_password echo_on api = Appfront::API.new(email: email, password: pass) key = api.login netrc.delete 'jarvis.appfront.io' netrc['jarvis.appfront.io'] = email, key netrc.save true end |
.logout ⇒ Object
55 56 57 58 59 60 |
# File 'lib/appfront/command/auth.rb', line 55 def self.logout netrc.delete 'jarvis.appfront.io' netrc.save true end |
.signup ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/appfront/command/auth.rb', line 27 def self.signup puts "Welcome to Appfront \n" puts "Insert your credentials to signup" print "email: " email = ask print "password: " echo_off pass = ask_for_password echo_on api = Appfront::API.new(email: email, password: pass) key = api.signup unless key exit 1 puts "There was a problem during registration, please try it later. \n" end netrc.delete 'jarvis.appfront.io' netrc['jarvis.appfront.io'] = email, key netrc.save puts "Registration complete, we've already logged you in... \n" puts "Find out more by typing: appfront help\n" true end |