Sha256: 0da36ca7f028aa87955692bdcd6fd75792688cb9b33a4570cb57dd917adabcb3
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
class PasswordResetsController < ApplicationController before_action :load_user_using_perishable_token, :only => [:show, :update] skip_before_action :require_user respond_to :html def index end def create @user = SpudUser.find_by_email(params[:email]) if @user @user.reset_perishable_token! CoreMailer.forgot_password_notification(@user, password_reset_url(@user.perishable_token)).deliver flash[:notice] = "Password reset instructions have been sent to your email" redirect_to login_path else flash.now[:error] = "No user was found with that email address" render 'index' end end def show end def update if params[:spud_user][:password].blank? @user.errors.add(:password, 'must not be blank') else @user.password = params[:spud_user][:password] @user.password_confirmation = params[:spud_user][:password_confirmation] if @user.save() SpudUserSession.create(@user) flash[:notice] = "Password successfully updated" redirect_back_or_default(root_path) return end end render 'show' end private def load_user_using_perishable_token @user = SpudUser.find_using_perishable_token(params[:id]) unless @user flash[:error] = "Password reset token was invalid or expired" redirect_to login_path end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tb_core-1.2.8 | app/controllers/password_resets_controller.rb |