Class: LinkedRails::Auth::Password

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#passwordObject

Returns the value of attribute password.



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

def password
  @password
end

#password_confirmationObject

Returns the value of attribute password_confirmation.



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

def password_confirmation
  @password_confirmation
end

#reset_password_tokenObject

Returns the value of attribute reset_password_token.



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

def reset_password_token
  @reset_password_token
end

#userObject

Returns the value of attribute user.



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

def user
  @user
end

Class Method Details

.action_listObject



14
15
16
# File 'app/models/linked_rails/auth/password.rb', line 14

def action_list
  LinkedRails.password_action_list_class
end

.decrypt_token(token) ⇒ Object



18
19
20
# File 'app/models/linked_rails/auth/password.rb', line 18

def decrypt_token(token)
  Devise.token_generator.digest(self, :reset_password_token, token)
end

.form_classObject



22
23
24
# File 'app/models/linked_rails/auth/password.rb', line 22

def form_class
  LinkedRails.password_form_class
end

.iri_namespaceObject



26
27
28
# File 'app/models/linked_rails/auth/password.rb', line 26

def iri_namespace
  Vocab.ontola
end

.requested_singular_resource(params, _user_context) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'app/models/linked_rails/auth/password.rb', line 30

def requested_singular_resource(params, _user_context)
  reset_password_token = decrypt_token(params[:reset_password_token])
  user_by_token ||= LinkedRails.user_class.find_by(reset_password_token: reset_password_token)
  return new(reset_password_token: params[:reset_password_token]) if user_by_token.blank?

  new(
    reset_password_token: params[:reset_password_token],
    user: user_by_token
  )
end

.singular_route_keyObject



41
42
43
# File 'app/models/linked_rails/auth/password.rb', line 41

def singular_route_key
  'u/password'
end