Sha256: f9e5186bf36af93533e0b76cff999060da741e1ef8cd17d3898608a45b501f3f

Contents?: true

Size: 810 Bytes

Versions: 1

Compression:

Stored size: 810 Bytes

Contents

class PasswordResetController < ApplicationController
  def show
  end

  def create
    username_or_email = "#{params[:email]}".downcase
    user = User.find_by_username_or_email(username_or_email) if username_or_email.present?

    if user && user.send_reset_password
      logout

      respond_to do |format|
        format.json { head :no_content }
        format.html {
          flash[:notice] = "We've sent an email which can be used to change your password"
          redirect_to login_path
        }
      end
    else
      respond_to do |format|
        format.json { render json: { errors: ["Invalid user name or email"], status: "error" }, status: 422 }
        format.html {
          flash.now[:error] = "Invalid user name or email"
          render :show
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authkit-0.0.1 lib/generators/authkit/templates/app/controllers/password_reset_controller.rb