2013-06-13 12:53:04 -04:00
|
|
|
class PasswordsController < ApplicationController
|
|
|
|
layout 'navless'
|
|
|
|
|
2013-06-13 13:16:48 -04:00
|
|
|
skip_before_filter :check_password_expiration
|
|
|
|
|
2013-06-13 12:53:04 -04:00
|
|
|
before_filter :set_user
|
|
|
|
before_filter :set_title
|
|
|
|
|
|
|
|
def new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
new_password = params[:user][:password]
|
|
|
|
new_password_confirmation = params[:user][:password_confirmation]
|
|
|
|
|
|
|
|
result = @user.update_attributes(
|
|
|
|
password: new_password,
|
|
|
|
password_confirmation: new_password_confirmation
|
|
|
|
)
|
|
|
|
|
|
|
|
if result
|
2013-06-13 13:21:51 -04:00
|
|
|
@user.update_attributes(password_expires_at: nil)
|
|
|
|
redirect_to root_path, notice: 'Password successfully changed'
|
2013-06-13 12:53:04 -04:00
|
|
|
else
|
|
|
|
render :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_user
|
|
|
|
@user = current_user
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_title
|
|
|
|
@title = "New password"
|
|
|
|
end
|
|
|
|
end
|