From 3e09e6f7b8032859a82266282dfd35715b3b3727 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Jun 2013 18:24:14 +0300 Subject: Move Profile related controllers under Profiles:: module --- app/controllers/profiles/passwords_controller.rb | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 app/controllers/profiles/passwords_controller.rb (limited to 'app/controllers/profiles/passwords_controller.rb') diff --git a/app/controllers/profiles/passwords_controller.rb b/app/controllers/profiles/passwords_controller.rb new file mode 100644 index 00000000000..432899f857d --- /dev/null +++ b/app/controllers/profiles/passwords_controller.rb @@ -0,0 +1,38 @@ +class Profiles::PasswordsController < ApplicationController + layout 'navless' + + skip_before_filter :check_password_expiration + + 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 + @user.update_attributes(password_expires_at: nil) + redirect_to root_path, notice: 'Password successfully changed' + else + render :new + end + end + + private + + def set_user + @user = current_user + end + + def set_title + @title = "New password" + end +end -- cgit v1.2.1