Sha256: 8d70b19648ec0690d77a64ebab4ff89efeec72a27d85921b1076c0fea12e596e

Contents?: true

Size: 1.06 KB

Versions: 29

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])
      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[:reset_token])
    end

    def update
      @user = User.find_by(reset_token: params[:reset_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

29 entries across 29 versions & 1 rubygems

Version Path
wbase-0.3.0 app/controllers/wbase/password_resets_controller.rb
wbase-0.2.9 app/controllers/wbase/password_resets_controller.rb
wbase-0.2.8 app/controllers/wbase/password_resets_controller.rb
wbase-0.2.7 app/controllers/wbase/password_resets_controller.rb
wbase-0.2.6 app/controllers/wbase/password_resets_controller.rb
wbase-0.2.5 app/controllers/wbase/password_resets_controller.rb
wbase-0.2.4 app/controllers/wbase/password_resets_controller.rb
wbase-0.2.3 app/controllers/wbase/password_resets_controller.rb
wbase-0.2.2 app/controllers/wbase/password_resets_controller.rb
wbase-0.2.1 app/controllers/wbase/password_resets_controller.rb
wbase-0.2.0 app/controllers/wbase/password_resets_controller.rb
wbase-0.1.7 app/controllers/wbase/password_resets_controller.rb
wbase-0.1.6 app/controllers/wbase/password_resets_controller.rb
wbase-0.1.5 app/controllers/wbase/password_resets_controller.rb
wbase-0.1.4 app/controllers/wbase/password_resets_controller.rb
wbase-0.1.3 app/controllers/wbase/password_resets_controller.rb
wbase-0.1.2 app/controllers/wbase/password_resets_controller.rb
wbase-0.1.0 app/controllers/wbase/password_resets_controller.rb
wbase-0.0.15 app/controllers/wbase/password_resets_controller.rb
wbase-0.0.14 app/controllers/wbase/password_resets_controller.rb