Module: Genius::Auth
- Defined in:
- lib/genius/api/authorization.rb
Overview
Genius::Auth module is used to authenticate users with their token. It provides initialization of token instance variable.
Class Method Summary collapse
-
.authorized?(token = @token, method_name: "#{Module.nesting[1].name}.#{__method__}") ⇒ Boolean
Checks if the current token is authorized.
-
.logout! ⇒ nil
Revokes the current session by setting the token to
nil. -
.token=(token) ⇒ String
(also: login=)
Sets the authentication token after validation.
Class Method Details
.authorized?(token = @token, method_name: "#{Module.nesting[1].name}.#{__method__}") ⇒ Boolean
Checks if the current token is authorized. Returns false on validation failure.
27 28 29 30 31 32 33 |
# File 'lib/genius/api/authorization.rb', line 27 def (token = @token, method_name: "#{Module.nesting[1].name}.#{__method__}") Errors.validate_token(token, method_name: method_name) rescue Genius::Errors::TokenError false else true end |
.logout! ⇒ nil
Revokes the current session by setting the token to nil.
38 39 40 |
# File 'lib/genius/api/authorization.rb', line 38 def logout! @token = nil unless @token.nil? end |
.token=(token) ⇒ String Also known as: login=
Sets the authentication token after validation.
16 17 18 19 |
# File 'lib/genius/api/authorization.rb', line 16 def token=(token) Genius::Errors.validate_token(token) @token = token end |