Class: LinkedRails::Auth::Unlock
- Inherits:
-
Resource
- Object
- Resource
- LinkedRails::Auth::Unlock
- Defined in:
- app/models/linked_rails/auth/unlock.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#unlock_token ⇒ Object
Returns the value of attribute unlock_token.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
- .action_list ⇒ Object
- .decrypt_token(token) ⇒ Object
- .form_class ⇒ Object
- .iri_namespace ⇒ Object
- .requested_singular_resource(params, _user_context) ⇒ Object
- .singular_iri_template ⇒ Object
- .singular_route_key ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
10 11 12 |
# File 'app/models/linked_rails/auth/unlock.rb', line 10 def email @email end |
#unlock_token ⇒ Object
Returns the value of attribute unlock_token.
10 11 12 |
# File 'app/models/linked_rails/auth/unlock.rb', line 10 def unlock_token @unlock_token end |
#user ⇒ Object
Returns the value of attribute user.
10 11 12 |
# File 'app/models/linked_rails/auth/unlock.rb', line 10 def user @user end |
Class Method Details
.action_list ⇒ Object
22 23 24 |
# File 'app/models/linked_rails/auth/unlock.rb', line 22 def action_list LinkedRails.unlock_action_list_class end |
.decrypt_token(token) ⇒ Object
26 27 28 |
# File 'app/models/linked_rails/auth/unlock.rb', line 26 def decrypt_token(token) Devise.token_generator.digest(self, :unlock_token, token) end |
.form_class ⇒ Object
30 31 32 |
# File 'app/models/linked_rails/auth/unlock.rb', line 30 def form_class LinkedRails.unlock_form_class end |
.iri_namespace ⇒ Object
34 35 36 |
# File 'app/models/linked_rails/auth/unlock.rb', line 34 def iri_namespace Vocab.ontola end |
.requested_singular_resource(params, _user_context) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'app/models/linked_rails/auth/unlock.rb', line 46 def requested_singular_resource(params, _user_context) token = decrypt_token(token) user_by_token ||= LinkedRails.user_class.find_by(unlock_token: token) return new(unlock_token: params[:unlock_token]) if user_by_token.blank? new( unlock_token: params[:unlock_token], user: user_by_token ) end |
.singular_iri_template ⇒ Object
38 39 40 |
# File 'app/models/linked_rails/auth/unlock.rb', line 38 def singular_iri_template @singular_iri_template ||= URITemplate.new("/#{singular_route_key}{?unlock_token}") end |
.singular_route_key ⇒ Object
42 43 44 |
# File 'app/models/linked_rails/auth/unlock.rb', line 42 def singular_route_key 'u/unlock' end |
Instance Method Details
#anonymous_iri? ⇒ Boolean
13 14 15 |
# File 'app/models/linked_rails/auth/unlock.rb', line 13 def anonymous_iri? unlock_token.blank? end |
#singular_iri_opts ⇒ Object
17 18 19 |
# File 'app/models/linked_rails/auth/unlock.rb', line 17 def singular_iri_opts {unlock_token: unlock_token} end |