Sha256: f33f6898ed2a17b48acb06360a2cca5d315f36cdc826ccb3bb494d9ee7e45f05

Contents?: true

Size: 807 Bytes

Versions: 9

Compression:

Stored size: 807 Bytes

Contents

# frozen_string_literal: true

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: t(".notice")
    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

9 entries across 9 versions & 1 rubygems

Version Path
minimalist_authentication-3.1.0 app/controllers/passwords_controller.rb
minimalist_authentication-3.0.0 app/controllers/passwords_controller.rb
minimalist_authentication-2.7.0 app/controllers/passwords_controller.rb
minimalist_authentication-2.6.2 app/controllers/passwords_controller.rb
minimalist_authentication-2.6.1 app/controllers/passwords_controller.rb
minimalist_authentication-2.6.0 app/controllers/passwords_controller.rb
minimalist_authentication-2.5.2 app/controllers/passwords_controller.rb
minimalist_authentication-2.5.1 app/controllers/passwords_controller.rb
minimalist_authentication-2.5.0 app/controllers/passwords_controller.rb