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
|
def reset_bounce_score
|
||||||
guardian.ensure_can_reset_bounce_score!(@user)
|
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
|
render json: success_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,10 @@ class UsersEmailController < ApplicationController
|
||||||
updater = EmailUpdater.new
|
updater = EmailUpdater.new
|
||||||
@update_result = updater.confirm(params[:token])
|
@update_result = updater.confirm(params[:token])
|
||||||
|
|
||||||
# Log in the user if the process is complete (and they're not logged in)
|
if @update_result == :complete
|
||||||
log_on_user(updater.user) if @update_result == :complete
|
updater.user.user_stat.reset_bounce_score!
|
||||||
|
log_on_user(updater.user)
|
||||||
|
end
|
||||||
|
|
||||||
render layout: 'no_ember'
|
render layout: 'no_ember'
|
||||||
end
|
end
|
||||||
|
|
|
@ -985,7 +985,6 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def hash_password(password, salt)
|
def hash_password(password, salt)
|
||||||
raise StandardError.new("password is too long") if password.size > User.max_password_length
|
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)
|
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)
|
cache_last_seen(Time.now.to_f)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reset_bounce_score!
|
||||||
|
update_columns(reset_bounce_score_after: nil, bounce_score: 0)
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def trigger_badges
|
def trigger_badges
|
||||||
|
|
|
@ -255,7 +255,6 @@ describe UsersController do
|
||||||
user.reload
|
user.reload
|
||||||
|
|
||||||
expect(session["password-#{token}"]).to be_blank
|
expect(session["password-#{token}"]).to be_blank
|
||||||
|
|
||||||
expect(UserAuthToken.where(id: user_auth_token.id).count).to eq(0)
|
expect(UserAuthToken.where(id: user_auth_token.id).count).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,17 @@ describe UsersEmailController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'confirms with a correct token' do
|
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
|
get :confirm, token: user.email_tokens.last.token
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
expect(assigns(:update_result)).to eq(:complete)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -190,6 +190,8 @@ describe User do
|
||||||
|
|
||||||
it "has correct settings" do
|
it "has correct settings" do
|
||||||
expect(subject.email_tokens).to be_present
|
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_private_messages).to eq(true)
|
||||||
expect(subject.user_option.email_direct).to eq(true)
|
expect(subject.user_option.email_direct).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue