Sha256: 22116e3b921b6c5de1912e21633d79a1e158ce5c066b1a0a3321dd99738c2910

Contents?: true

Size: 795 Bytes

Versions: 11

Compression:

Stored size: 795 Bytes

Contents

class PasswordsController < ApplicationController
  skip_before_action :authorization_required

  layout 'sessions'

  # From for user to update password
  def edit
    redirect_to(new_session_path) unless user.matches_verification_token?(token)
    # render passwords/edit.html.erb
  end

  # Update user's password
  def update
    if user.secure_update(token, password_params.merge(password_required: true))
      redirect_to new_session_path, notice: 'Password successfully updated'
    else
      render :edit
    end
  end

  private

  def user
    @user ||= MinimalistAuthentication.configuration.user_model.find(params[:user_id])
  end

  def token
    @token ||= params[:token]
  end

  def password_params
    params.require(:user).permit(:password, :password_confirmation)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
minimalist_authentication-2.4.0 app/controllers/passwords_controller.rb
minimalist_authentication-2.3.0 app/controllers/passwords_controller.rb
minimalist_authentication-2.2.4 app/controllers/passwords_controller.rb
minimalist_authentication-2.2.3 app/controllers/passwords_controller.rb
minimalist_authentication-2.2.2 app/controllers/passwords_controller.rb
minimalist_authentication-2.2.1 app/controllers/passwords_controller.rb
minimalist_authentication-2.2.0 app/controllers/passwords_controller.rb
minimalist_authentication-2.1.5 app/controllers/passwords_controller.rb
minimalist_authentication-2.1.4 app/controllers/passwords_controller.rb
minimalist_authentication-2.1.3 app/controllers/passwords_controller.rb
minimalist_authentication-2.1.2 app/controllers/passwords_controller.rb