Class: LinkedRails::Auth::Unlock

Inherits:
Resource
  • Object
show all
Defined in:
app/models/linked_rails/auth/unlock.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#emailObject

Returns the value of attribute email.



10
11
12
# File 'app/models/linked_rails/auth/unlock.rb', line 10

def email
  @email
end

#unlock_tokenObject

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

#userObject

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_listObject



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_classObject



30
31
32
# File 'app/models/linked_rails/auth/unlock.rb', line 30

def form_class
  LinkedRails.unlock_form_class
end

.iri_namespaceObject



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_templateObject



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_keyObject



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

Returns:

  • (Boolean)


13
14
15
# File 'app/models/linked_rails/auth/unlock.rb', line 13

def anonymous_iri?
  unlock_token.blank?
end

#singular_iri_optsObject



17
18
19
# File 'app/models/linked_rails/auth/unlock.rb', line 17

def singular_iri_opts
  {unlock_token: unlock_token}
end