module Simplewoo::Authentication
Public Instance Methods
authenticate(args = {})
click to toggle source
Authenticates the user with their email and password returning an api token
@option args [String] email - the email of the user @option args [String] password - the password of the user
# 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?()
click to toggle source
# File lib/simplewoo/authentication.rb, line 16 def authenticated? !!(basic_authenticated? || token_authenticated? || trusted_authenticated?) end
basic_authenticated?()
click to toggle source
# File lib/simplewoo/authentication.rb, line 4 def basic_authenticated? !!(self.email && self.password) end
token_authenticated?()
click to toggle source
# File lib/simplewoo/authentication.rb, line 8 def token_authenticated? !!(self.api_token) end
trusted_authenticated?()
click to toggle source
# File lib/simplewoo/authentication.rb, line 12 def trusted_authenticated? !!(self.trusted && self.email) end