Class: ReviseAuth::EmailController

Inherits:
ReviseAuthController show all
Defined in:
app/controllers/revise_auth/email_controller.rb

Instance Method Summary collapse

Methods inherited from ReviseAuthController

#revise_auth_controller?

Methods included from Authentication

#authenticate_user, #authenticate_user!, #authenticated_user_from_session, #current_user, #login, #logout, #reset_session, #user_signed_in?

Instance Method Details

#showObject

GET /profile/email?confirmation_token=abcdef



5
6
7
8
9
10
11
12
# File 'app/controllers/revise_auth/email_controller.rb', line 5

def show
  if User.find_by(confirmation_token: params[:confirmation_token])&.confirm_email_change
    # flash[:notice] = I18n.t("revise_auth.email_confirmed")
    redirect_to(user_signed_in? ? profile_path : root_path)
  else
    redirect_to root_path, alert: I18n.t("revise_auth.email_confirm_failed")
  end
end

#updateObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/revise_auth/email_controller.rb', line 14

def update
  email = current_user.email
  current_user.update(email_params)
  if email != params[:user][:unconfirmed_email]
    current_user.confirmation_sent_at = Time.now
    current_user.save
    current_user.send_confirmation_instructions
    # flash[:notice] = I18n.t("revise_auth.confirmation_email_sent", email: current_user.unconfirmed_email)
  end

  redirect_to profile_path
end