Module: RegistrationTokenValidation

Extended by:
ActiveSupport::Concern
Included in:
Teams::RegistrationsController
Defined in:
app/controllers/concerns/registration_token_validation.rb

Instance Method Summary collapse

Instance Method Details

#registration_token_resolves?Boolean



16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/concerns/registration_token_validation.rb', line 16

def registration_token_resolves?
  encrypted_token = Devise.token_generator.digest(
    Jobshop::Team, :registration_token, params[:registration_token])

  configurable = Jobshop::Team.find_by(
    id: params[:team_id], registration_token: encrypted_token)

  configurable &&
    configurable.registration_token_period_valid? &&
    configurable.owner.blank?
end

#registration_token_valid?Boolean



12
13
14
# File 'app/controllers/concerns/registration_token_validation.rb', line 12

def registration_token_valid?
  params[:registration_token].present? && registration_token_resolves?
end

#validate_registration_token!Object



8
9
10
# File 'app/controllers/concerns/registration_token_validation.rb', line 8

def validate_registration_token!
  redirect_to new_user_session_path unless registration_token_valid?
end