-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix user account deletion not working #26212
Fix user account deletion not working #26212
Conversation
@techknowlogick Need your feedback on this approach. |
I think we should limit the use of |
No, I don't think it's right. We need to enumerate all possible errors. |
But it is limited to password check and do you want the whole Could you suggest something in one or two liner the approach. It will be easy for me to understand. |
At least, to resolve #26210, you could catch paswrod is invalid error and display it in the UI and let other errors return 500. Some errors are affected by wrong user's input, some are from system problems. We need to diff these two kinds of errors. |
Ohh, I got it now. Sending the fix in a few |
see #26210 (comment) |
I will share couple samples of implementation in the followups. Apologies for this, _, _, err := auth.UserSignIn(ctx.Doer.Name, ctx.FormString("password"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
loadAccountData(ctx)
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), tplSettingsAccount, nil)
} else if errors.Is(err, err.(db.ErrUserPasswordNotSet)) {
ctx.RenderWithErr(ctx.Tr("form.password_not_set_on_user_account"), tplSettingsAccount, nil)
} else if errors.Is(err, err.(db.ErrUserPasswordInvalid)) {
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), tplSettingsAccount, nil)
} else if user_model.IsErrUserProhibitLogin(err) {
ctx.RenderWithErr(ctx.Tr("auth.prohibit_login"), tplSettingsAccount, nil)
} else {
ctx.ServerError("UserSignIn", err)
}
return
} this is the approach I was thinging about |
routers/web/user/setting/account.go
Outdated
@@ -234,7 +234,11 @@ func DeleteEmail(ctx *context.Context) { | |||
func DeleteAccount(ctx *context.Context) { | |||
ctx.Data["Title"] = ctx.Tr("settings") | |||
ctx.Data["PageIsSettingsAccount"] = true | |||
|
|||
passwd := ctx.FormString("password") | |||
if len(passwd) == 0 || !ctx.Doer.ValidatePassword(passwd) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making this change. auth.UserSignIn
below should return ErrUserPasswordInvalid
if the password is invalid, so perhaps that could be checked in an if conditional instead (pseudocode err == ErrUserPasswordInvalid
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add this check too. But lil bit confused with the error stack that I have create in above comments are right way of doing it? Need a bit of help there.
The committed solution will just works as fine. But there are other errors thats may occurs that needs to be covered.
routers/web/user/setting/account.go
Outdated
passwd := ctx.FormString("password") | ||
if len(passwd) == 0 || !ctx.Doer.ValidatePassword(passwd) { | ||
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), tplSettingsAccount, nil) | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it work with external auth sources? eg: LDAP, the passwd
field is empty.
(the first question is: should Gitea support deleting LDAP accounts?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lunny Need your help on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we need to check whether password is set before check popup the password dialog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean we need an api call from frontend that will check the password is set on the account?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking that, there are still some edge cases remaining before we implement the solution around this 500 error.
I'm keeping this PR open for the further discussion and will raise a complete new PR.
6637886
to
efecbba
Compare
as title:
Fixes: #26210