Fix `NilClass` error in `UsersController`.
This commit is contained in:
parent
aca972c08b
commit
406d721f11
|
@ -392,11 +392,11 @@ class UsersController < ApplicationController
|
||||||
token = params[:token]
|
token = params[:token]
|
||||||
|
|
||||||
if EmailToken.valid_token_format?(token)
|
if EmailToken.valid_token_format?(token)
|
||||||
|
@user =
|
||||||
if request.put?
|
if request.put?
|
||||||
@user = EmailToken.confirm(token)
|
EmailToken.confirm(token)
|
||||||
else
|
else
|
||||||
email_token = EmailToken.confirmable(token)
|
EmailToken.confirmable(token)&.user
|
||||||
@user = email_token.try(:user)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if @user
|
if @user
|
||||||
|
@ -438,11 +438,11 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
format.json do
|
format.json do
|
||||||
if request.put?
|
if request.put?
|
||||||
if @error || @user.errors&.any?
|
if @error || @user&.errors&.any?
|
||||||
render json: {
|
render json: {
|
||||||
success: false,
|
success: false,
|
||||||
message: @error,
|
message: @error,
|
||||||
errors: @user.errors.to_hash,
|
errors: @user&.errors.to_hash,
|
||||||
is_developer: UsernameCheckerService.is_developer?(@user.email)
|
is_developer: UsernameCheckerService.is_developer?(@user.email)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue