Class: Appfront::Command::Auth

Inherits:
Base
  • Object
show all
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?
  
end

.credentialsObject



67
68
69
# File 'lib/appfront/command/auth.rb', line 67

def self.credentials
  netrc['jarvis.appfront.io']
end

.loginObject



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.
  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.

  netrc.delete 'jarvis.appfront.io'

  netrc['jarvis.appfront.io'] = email, key
  netrc.save

  true
end

.logoutObject



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

.signupObject



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.
  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.
  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