Class: Foobara::Auth::CreateResetPasswordToken

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

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Attribute Summary collapse

Attributes included from CommandPatternImplementation::Concerns::Subcommands

#is_subcommand

Attributes included from CommandPatternImplementation::Concerns::Runtime

#exception, #outcome

Attributes included from CommandPatternImplementation::Concerns::Errors

#error_collection

Attributes included from CommandPatternImplementation::Concerns::Inputs

#inputs, #raw_inputs

Instance Method Summary collapse

Methods inherited from Command

install!, reset_all

Methods included from Concern

foobara_class_methods_module_for, foobara_concern?, included

Methods included from CommandPatternImplementation::Concerns::Reflection

#initialize

Methods included from CommandPatternImplementation::Concerns::DomainMappers

#domain_map, #domain_map!, #run_mapped_subcommand!

Methods included from CommandPatternImplementation::Concerns::Subcommands

#run_subcommand!, #subcommand?

Methods included from CommandPatternImplementation::Concerns::Entities

#load_entities, #load_records

Methods included from CommandPatternImplementation::Concerns::Transactions

#relevant_entity_classes

Methods included from NestedTransactionable

#auto_detect_current_transactions, #commit_transaction, #commit_transaction_if_open, #open_transaction, #opened_transactions, #relevant_entity_classes, relevant_entity_classes_for_type, #relevant_entity_classes_for_type, #rollback_transaction, #transactions, #use_transaction

Methods included from CommandPatternImplementation::Concerns::StateMachine

#state_machine

Methods included from CommandPatternImplementation::Concerns::Runtime

#halt!, #run, #run!, #run_execute, #succeed, #success?, #validate, #validate_records

Methods included from CommandPatternImplementation::Concerns::Errors

#initialize

Methods included from CommandPatternImplementation::Concerns::Inputs

#cast_and_validate_inputs, #initialize, #method_missing, #respond_to_missing?, #respond_to_missing_for_inputs?

Methods included from TruncatedInspect

#inspect, truncating

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Foobara::CommandPatternImplementation::Concerns::Inputs

Instance Attribute Details

#expires_atObject

Returns the value of attribute expires_at.


26
27
28
# File 'foobara-auth-0.0.13/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 'foobara-auth-0.0.13/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 'foobara-auth-0.0.13/src/create_reset_password_token.rb', line 26

def reset_password_token_secret
  @reset_password_token_secret
end

Instance Method Details

#determine_timestampsObject

[View source]

28
29
30
31
# File 'foobara-auth-0.0.13/src/create_reset_password_token.rb', line 28

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

#executeObject

[View source]

17
18
19
20
21
22
23
24
# File 'foobara-auth-0.0.13/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

[View source]

33
34
35
36
37
38
# File 'foobara-auth-0.0.13/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

[View source]

40
41
42
# File 'foobara-auth-0.0.13/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