Sha256: a1c1c4a78a357af6d8fb8700c369c1421fccf9c77cd9f15f4ab8046e159e6a0d

Contents?: true

Size: 1.06 KB

Versions: 12

Compression:

Stored size: 1.06 KB

Contents

require_dependency "wbase/application_controller"

module Wbase
  class PasswordResetsController < ApplicationController
    layout 'wbase/auth'

    def new
    end

    def create
      # If the user is found, generate password reset
      user = User.find_by(email: params[:email].try(:downcase))
      if user
        user.reset_reset_token!
        PasswordResetMailer.reset(user).deliver_later
      end
      flash.now[:alert] = "Thanks! If we find a user with that email, we'll be in touch"
      render :new
    end

    def edit
      @user = User.find_by(reset_token: params[:token])
    end

    def update
      @user = User.find_by(reset_token: params[:token])
      if @user
        @user.password = params[:password]
        if @user.save
          login(@user)
          redirect_to '/'
        else
          flash.now[:errors] = @user.errors.full_messages
          render :edit
        end
      else
        flash.now[:errors] = [
          "Hmmm. We didn't find a user with that password reset token :/. try again?"]
        render :edit
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
wbase-0.3.20 app/controllers/wbase/password_resets_controller.rb
wbase-0.3.19 app/controllers/wbase/password_resets_controller.rb
wbase-0.3.18 app/controllers/wbase/password_resets_controller.rb
wbase-0.3.17 app/controllers/wbase/password_resets_controller.rb
wbase-0.3.16 app/controllers/wbase/password_resets_controller.rb
wbase-0.3.15 app/controllers/wbase/password_resets_controller.rb
wbase-0.3.14 app/controllers/wbase/password_resets_controller.rb
wbase-0.3.13 app/controllers/wbase/password_resets_controller.rb
wbase-0.3.12 app/controllers/wbase/password_resets_controller.rb
wbase-0.3.11 app/controllers/wbase/password_resets_controller.rb
wbase-0.3.10 app/controllers/wbase/password_resets_controller.rb
wbase-0.3.9 app/controllers/wbase/password_resets_controller.rb