FIX: Set user timezone on password reset login (#9461)
This commit is contained in:
parent
80563705da
commit
0e74dd7d7c
|
@ -54,7 +54,8 @@ export default Controller.extend(PasswordValidation, {
|
|||
password: this.accountPassword,
|
||||
second_factor_token:
|
||||
this.securityKeyCredential || this.secondFactorToken,
|
||||
second_factor_method: this.secondFactorMethod
|
||||
second_factor_method: this.secondFactorMethod,
|
||||
timezone: moment.tz.guess()
|
||||
}
|
||||
})
|
||||
.then(result => {
|
||||
|
|
|
@ -641,6 +641,7 @@ class UsersController < ApplicationController
|
|||
# if we have run into no errors then the user is a-ok to
|
||||
# change the password
|
||||
if @user.errors.empty?
|
||||
@user.update_timezone_if_missing(params[:timezone]) if params[:timezone]
|
||||
@user.password = params[:password]
|
||||
@user.password_required!
|
||||
@user.user_auth_tokens.destroy_all
|
||||
|
|
|
@ -279,6 +279,18 @@ describe UsersController do
|
|||
expect(response).to redirect_to(wizard_path)
|
||||
end
|
||||
|
||||
it "sets the users timezone if the param is present" do
|
||||
user = Fabricate(:admin)
|
||||
UserAuthToken.generate!(user_id: user.id)
|
||||
|
||||
token = user.email_tokens.create(email: user.email).token
|
||||
get "/u/password-reset/#{token}"
|
||||
|
||||
expect(user.user_option.timezone).to eq(nil)
|
||||
put "/u/password-reset/#{token}", params: { password: 'hg9ow8yhg98oadminlonger', timezone: "America/Chicago" }
|
||||
expect(user.user_option.reload.timezone).to eq("America/Chicago")
|
||||
end
|
||||
|
||||
it "logs the password change" do
|
||||
user = Fabricate(:admin)
|
||||
UserAuthToken.generate!(user_id: user.id)
|
||||
|
|
Loading…
Reference in New Issue