Class: DouguiUsers::UserResetPasswordsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/dougui_users/user_reset_passwords_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#load_user_using_perishable_token

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/dougui_users/user_reset_passwords_controller.rb', line 9

def create
  @user = DouguiUsers::User.find_by_email(params[:user][:email])
  if @user
    @user.reset_perishable_token!
    DouguiUsers::UserMailer.reset_password(@user).deliver
    redirect_to(, :notice => t("successfully_created", :scope => 'user_reset_passwords.controller'))
  else
    @user = DouguiUsers::User.new(:email => params[:user][:email])
    @user.valid?
    unless @user.errors[:email].any?
      @user.errors[:email] = t("unknown_email", :scope => 'user_reset_passwords.controller')
    end
    render :new
  end
end

#editObject



25
26
27
# File 'app/controllers/dougui_users/user_reset_passwords_controller.rb', line 25

def edit
  @user = DouguiUsers::User.find_by_perishable_token params[:id]
end

#newObject



6
7
# File 'app/controllers/dougui_users/user_reset_passwords_controller.rb', line 6

def new
end

#updateObject



29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/dougui_users/user_reset_passwords_controller.rb', line 29

def update
  @user = DouguiUsers::User.find_by_perishable_token params[:id]
  @user.password = params[:user][:password]
  @user.password_confirmation = params[:user][:password_confirmation]
  if @user.save
    redirect_to(root_path, :notice => t("successfully_updated", :scope => 'user_reset_passwords.controller'))
  else
    render :edit
  end
end