Module: Simplewoo::Authentication
- Included in:
- Client
- Defined in:
- lib/simplewoo/authentication.rb
Instance Method Summary collapse
- #api_token ⇒ Object
-
#authenticate(args = {}) ⇒ Object
Authenticates the user with their email and password returning an api token.
- #authenticated? ⇒ Boolean
- #basic_authenticated? ⇒ Boolean
- #token_authenticated? ⇒ Boolean
Instance Method Details
#api_token ⇒ Object
16 17 18 |
# File 'lib/simplewoo/authentication.rb', line 16 def api_token self.api_token ||= authenticate if authenticated? end |
#authenticate(args = {}) ⇒ Object
Authenticates the user with their email and password returning an api token
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/simplewoo/authentication.rb', line 24 def authenticate(args = {}) self.email ||= args.delete(:email) self.password ||= args.delete(:password) unless token_authenticated? self.api_token = me.access_token end self.api_token end |
#authenticated? ⇒ Boolean
12 13 14 |
# File 'lib/simplewoo/authentication.rb', line 12 def authenticated? !!(basic_authenticated? || token_authenticated?) end |
#basic_authenticated? ⇒ Boolean
4 5 6 |
# File 'lib/simplewoo/authentication.rb', line 4 def basic_authenticated? !!(self.email && self.password) end |
#token_authenticated? ⇒ Boolean
8 9 10 |
# File 'lib/simplewoo/authentication.rb', line 8 def token_authenticated? !!(self.api_token) end |