Class: HaveAPI::Fs::Auth::Token
- Inherits:
-
Base
- Object
- Base
- HaveAPI::Fs::Auth::Token
show all
- Defined in:
- lib/haveapi/fs/auth/token.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#check, #initialize, method_name, #name, register
Class Method Details
.use?(opts) ⇒ Boolean
7
8
9
|
# File 'lib/haveapi/fs/auth/token.rb', line 7
def self.use?(opts)
opts[:token]
end
|
Instance Method Details
#authenticate(client) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/haveapi/fs/auth/token.rb', line 28
def authenticate(client)
if @token
opts = {token: @token}
else
opts = {user: @user, password: @passwd}
end
client.authenticate(:token, opts)
end
|
#setup ⇒ Object
11
12
13
14
15
|
# File 'lib/haveapi/fs/auth/token.rb', line 11
def setup
@user = @opts[:user] || @cfg[:user]
@passwd = @opts[:password] || @cfg[:password]
@token = @opts[:token] || @cfg[:token]
end
|
#validate ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/haveapi/fs/auth/token.rb', line 17
def validate
return if @token
@user ||= ask('User name: ') { |q| q.default = nil }.to_s
@passwd ||= ask('Password: ') do |q|
q.default = nil
q.echo = false
end.to_s
end
|