Class: Incline::PasswordResetsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/incline/password_resets_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /incline/password_resets



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/incline/password_resets_controller.rb', line 21

def create
  unless @reset_request.valid?
    render 'new' and return
  end

  @user = User.find_by(email: @reset_request.email)
  if @user && @user.enabled? && @user.activated?
    @user.create_reset_digest
    @user.send_password_reset_email request.remote_ip
  elsif @user
    if !@user.enabled?
      User.send_disabled_reset_email(email, request.remote_ip)
    elsif !@user.active?
      User.send_inactive_reset_email(email, request.remote_ip)
    else
      User.send_missing_reset_email(email, request.remote_ip)
    end
  else
    User.send_missing_reset_email(email, request.remote_ip)
  end

  flash[:info] = 'An email with password reset information has been sent to you.'
  redirect_to main_app.root_url
end

#editObject

GET /incline/password_resets/[email protected]



48
49
50
# File 'app/controllers/incline/password_resets_controller.rb', line 48

def edit

end

#newObject

GET /incline/password_resets/new



15
16
17
# File 'app/controllers/incline/password_resets_controller.rb', line 15

def new

end

#updateObject

POST /incline/password_resets/reset-token



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/controllers/incline/password_resets_controller.rb', line 54

def update
  unless @reset.valid?
    render 'edit' and return
  end

  if @user.update_attributes(password: @reset.password, password_confirmation: @reset.password)
     @user
    flash[:success] = 'Password has been reset.'
    redirect_to @user
  else
    @user.errors[:base] << 'Failed to reset password.'
    render 'edit'
  end
end