password recovery wip

This commit is contained in:
Karol Selak 2021-03-21 10:36:09 +01:00
parent cd40ef66c6
commit 49998ee5b7
12 changed files with 70 additions and 1 deletions

View file

@ -8,4 +8,29 @@ class UsersController < ApplicationController
session[:user_id] = @user.id
redirect_to '/welcome'
end
def send_password_recovery_email
@user = User.where(email: params['email']).first
UserMailer.with(user: @user).password_recovery.deliver_now
end
def password_recovery_email
end
def password_recovery
@recovery_code = params[:recovery_code]
@user_id = params[:id]
end
def recover_password
user = User.find(params[:user_id])
if user.password_recovery_code == params[:recovery_code]
user.password = params[:password]
user.password_confirmation = params[:repeated_password]
user.password_recovery_code = nil
if user.save
redirect_to '/welcome'
end
end
end
end