Class: Foobara::Auth::CreateResetPasswordToken

Inherits:
Command
  • Object
show all
Defined in:
foobara-auth-0.1.1/src/create_reset_password_token.rb

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Command

install!

Methods included from TruncatedInspect

#inspect, truncating

Methods included from Concern

foobara_class_methods_module_for, foobara_concern?, included

Instance Attribute Details

#expires_atObject

Returns the value of attribute expires_at.



26
27
28
# File 'src/create_reset_password_token.rb', line 26

def expires_at
  @expires_at
end

#reset_password_token_recordObject

Returns the value of attribute reset_password_token_record.



26
27
28
# File 'src/create_reset_password_token.rb', line 26

def reset_password_token_record
  @reset_password_token_record
end

#reset_password_token_secretObject

Returns the value of attribute reset_password_token_secret.



26
27
28
# File 'src/create_reset_password_token.rb', line 26

def reset_password_token_secret
  @reset_password_token_secret
end

Instance Method Details

#determine_timestampsObject



28
29
30
31
# File 'src/create_reset_password_token.rb', line 28

def determine_timestamps
  now = Time.now
  self.expires_at = now + token_ttl
end

#executeObject



17
18
19
20
21
22
23
24
# File 'src/create_reset_password_token.rb', line 17

def execute
  determine_timestamps

  generate_new_reset_password_token
  save_new_reset_password_token_on_user

  reset_password_token_secret
end

#generate_new_reset_password_tokenObject



33
34
35
36
37
38
# File 'src/create_reset_password_token.rb', line 33

def generate_new_reset_password_token
  result = run_subcommand!(CreateToken, expires_at:)

  self.reset_password_token_record = result[:token_record]
  self.reset_password_token_secret = result[:token_string]
end

#save_new_reset_password_token_on_userObject



40
41
42
# File 'src/create_reset_password_token.rb', line 40

def save_new_reset_password_token_on_user
  user.reset_password_token = reset_password_token_record
end