Prevent sending emails on Password Reset (#64)

This commit is contained in:
Justin Licata 2018-01-11 17:03:43 -06:00 committed by GitHub
parent 1cd870f02f
commit 78938509a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

@ -8,7 +8,7 @@ module Users
layout('unauthenticated', only: %w(edit update))
def create
if @token = @user.send_reset_password_instructions
if @token = @user.reset_password_token!
redirect_to(after_sending_reset_password_instructions_path_for(@user))
else
flash[:danger] = t('.create.fail')

@ -10,4 +10,8 @@ class User < ApplicationRecord
alias_method(:pending?, :valid_invitation?)
has_many(:tokens, foreign_key: :created_by_id, dependent: :destroy)
def reset_password_token!
set_reset_password_token # devise method
end
end

@ -25,4 +25,11 @@ class UserTest < ActiveSupport::TestCase
@user.destroy
end
end
test 'reset_password_token!' do
@user.save
assert_nil(@user.reset_password_sent_at)
assert_not_nil(@user.reset_password_token!)
assert_not_nil(@user.reload.reset_password_sent_at)
end
end