Sha256: b58a39650bdb71cc17800a0f1da4a6e919752e33ee603c47c56c187becba9388
Contents?: true
Size: 1.04 KB
Versions: 11
Compression:
Stored size: 1.04 KB
Contents
class Identity::PasswordResetsController < ApplicationController skip_before_action :authenticate <%- if options.lockable? -%> before_action :require_lock, only: :create <%- end -%> before_action :set_user, only: :update def create if @user = User.find_by(email: params[:email], verified: true) UserMailer.with(user: @user).password_reset.deliver_later else render json: { error: "You can't reset your password until you verify your email" }, status: :bad_request end end def update if @user.update(user_params) revoke_tokens; render(json: @user) else render json: @user.errors, status: :unprocessable_entity end end private def set_user @token = PasswordResetToken.find_signed!(params[:sid]); @user = @token.user rescue render json: { error: "That password reset link is invalid" }, status: :bad_request end def user_params params.permit(:password, :password_confirmation) end def revoke_tokens @user.password_reset_tokens.delete_all end end
Version data entries
11 entries across 11 versions & 1 rubygems