reset bounce score when email is successfully changed
This commit is contained in:
parent
4f32d9e9f7
commit
cb99f59ec3
|
@ -363,7 +363,7 @@ class Admin::UsersController < Admin::AdminController
|
|||
|
||||
def reset_bounce_score
|
||||
guardian.ensure_can_reset_bounce_score!(@user)
|
||||
@user.user_stat.update_columns(bounce_score: 0, reset_bounce_score_after: nil)
|
||||
@user.user_stat&.reset_bounce_score!
|
||||
render json: success_json
|
||||
end
|
||||
|
||||
|
|
|
@ -36,8 +36,10 @@ class UsersEmailController < ApplicationController
|
|||
updater = EmailUpdater.new
|
||||
@update_result = updater.confirm(params[:token])
|
||||
|
||||
# Log in the user if the process is complete (and they're not logged in)
|
||||
log_on_user(updater.user) if @update_result == :complete
|
||||
if @update_result == :complete
|
||||
updater.user.user_stat.reset_bounce_score!
|
||||
log_on_user(updater.user)
|
||||
end
|
||||
|
||||
render layout: 'no_ember'
|
||||
end
|
||||
|
|
|
@ -985,7 +985,6 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def hash_password(password, salt)
|
||||
raise StandardError.new("password is too long") if password.size > User.max_password_length
|
||||
Pbkdf2.hash_password(password, salt, Rails.configuration.pbkdf2_iterations, Rails.configuration.pbkdf2_algorithm)
|
||||
|
|
|
@ -77,6 +77,10 @@ class UserStat < ActiveRecord::Base
|
|||
cache_last_seen(Time.now.to_f)
|
||||
end
|
||||
|
||||
def reset_bounce_score!
|
||||
update_columns(reset_bounce_score_after: nil, bounce_score: 0)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def trigger_badges
|
||||
|
|
|
@ -255,7 +255,6 @@ describe UsersController do
|
|||
user.reload
|
||||
|
||||
expect(session["password-#{token}"]).to be_blank
|
||||
|
||||
expect(UserAuthToken.where(id: user_auth_token.id).count).to eq(0)
|
||||
end
|
||||
|
||||
|
|
|
@ -33,9 +33,17 @@ describe UsersEmailController do
|
|||
end
|
||||
|
||||
it 'confirms with a correct token' do
|
||||
user.user_stat.update_columns(bounce_score: 42, reset_bounce_score_after: 1.week.from_now)
|
||||
|
||||
get :confirm, token: user.email_tokens.last.token
|
||||
|
||||
expect(response).to be_success
|
||||
expect(assigns(:update_result)).to eq(:complete)
|
||||
|
||||
user.reload
|
||||
|
||||
expect(user.user_stat.bounce_score).to eq(0)
|
||||
expect(user.user_stat.reset_bounce_score_after).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -190,6 +190,8 @@ describe User do
|
|||
|
||||
it "has correct settings" do
|
||||
expect(subject.email_tokens).to be_present
|
||||
expect(subject.user_stat).to be_present
|
||||
expect(subject.user_profile).to be_present
|
||||
expect(subject.user_option.email_private_messages).to eq(true)
|
||||
expect(subject.user_option.email_direct).to eq(true)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue