mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:22 +08:00
Fix NilClass
error in UsersController
.
This commit is contained in:
parent
aca972c08b
commit
406d721f11
|
@ -392,12 +392,12 @@ class UsersController < ApplicationController
|
|||
token = params[:token]
|
||||
|
||||
if EmailToken.valid_token_format?(token)
|
||||
if request.put?
|
||||
@user = EmailToken.confirm(token)
|
||||
else
|
||||
email_token = EmailToken.confirmable(token)
|
||||
@user = email_token.try(:user)
|
||||
end
|
||||
@user =
|
||||
if request.put?
|
||||
EmailToken.confirm(token)
|
||||
else
|
||||
EmailToken.confirmable(token)&.user
|
||||
end
|
||||
|
||||
if @user
|
||||
secure_session["password-#{token}"] = @user.id
|
||||
|
@ -438,11 +438,11 @@ class UsersController < ApplicationController
|
|||
|
||||
format.json do
|
||||
if request.put?
|
||||
if @error || @user.errors&.any?
|
||||
if @error || @user&.errors&.any?
|
||||
render json: {
|
||||
success: false,
|
||||
message: @error,
|
||||
errors: @user.errors.to_hash,
|
||||
errors: @user&.errors.to_hash,
|
||||
is_developer: UsernameCheckerService.is_developer?(@user.email)
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue
Block a user