class Object
Constants
- EMAIL_CONFIRMATION_KEY
Public Instance Methods
after_sign_in_path()
click to toggle source
# File lib/generators/templates/controllers/sessions_controller.rb, line 28 def after_sign_in_path root_path end
confirm()
click to toggle source
# File lib/generators/templates/controllers/registrations_controller.rb, line 13 def confirm @<%= identity_model %>.confirm! redirect_to(root_path, notice: t(:'auto_auth.registrations.confirmed')) end def create @registration = Registration.new(registration_params) if <%= domain_model %> = @registration.save! sign_in!(<%= domain_model %>) <%= domain_model %>.<%= identity_model %>.send_confirmation_email redirect_to(root_path, notice: t(:'auto_auth.registrations.account_created')) else render :new end end private def setup_<%= identity_model %> <%= identity_model_class %>.verify_signature!(<%= identity_model_class %>::EMAIL_CONFIRMATION_KEY, params.require(:email_confirmation_token)) do |record, expires_at| if expires_at < Time.current redirect_to(root_path, alert: t(:'auto_auth.registrations.expired')) else @<%= identity_model %> = record end end end def registration_params params.require(:registration).permit(:name, :email, :password, :password_confirmation) end end
confirm!()
click to toggle source
# File lib/generators/templates/models/identity_model.rb, line 32 def confirm! self.confirmed_at = Time.current save(validate: false) end
confirmed?()
click to toggle source
# File lib/generators/templates/models/identity_model.rb, line 37 def confirmed? confirmed_at.present? end
destroy()
click to toggle source
# File lib/generators/templates/controllers/sessions_controller.rb, line 20 def destroy reset_session redirect_to(sign_in_path, alert: t(:'auto_auth.sessions.signed_out')) end
password_required?()
click to toggle source
# File lib/generators/templates/models/identity_model.rb, line 58 def password_required? !persisted? || !password.nil? || !password_confirmation.nil? end
password_reset_token()
click to toggle source
# File lib/generators/templates/models/identity_model.rb, line 50 def password_reset_token expires_at = 1.day.from_now expiration_token(expires_at, PASSWORD_RESET_KEY) end
registration_params()
click to toggle source
# File lib/generators/templates/controllers/registrations_controller.rb, line 42 def registration_params params.require(:registration).permit(:name, :email, :password, :password_confirmation) end
send_confirmation_email()
click to toggle source
# File lib/generators/templates/models/identity_model.rb, line 41 def send_confirmation_email <%= identity_mailer_class %>.confirm_email(self).deliver end def email_confirmation_token expires_at = 7.days.from_now expiration_token(expires_at, EMAIL_CONFIRMATION_KEY) end
uniqueness_of_email()
click to toggle source
# File lib/generators/templates/models/registration.rb, line 26 def uniqueness_of_email errors.add(:email, 'has already been taken') if <
update_email(new_email)
click to toggle source
# File lib/generators/templates/models/identity_model.rb, line 22 def update_email(new_email) self.email = new_email if email_changed? self.confirmed_at = nil save && send_confirmation_email else save end end