Merge pull request 'Do not require login_name & source_id for /admin/user/{username}' (#3278) from algernon/forgejo:leave-your-name-at-the-door into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3278 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
d07f12e010
5 changed files with 56 additions and 33 deletions
|
@ -192,9 +192,17 @@ func EditUser(ctx *context.APIContext) {
|
|||
|
||||
form := web.GetForm(ctx).(*api.EditUserOption)
|
||||
|
||||
// If either LoginSource or LoginName is given, the other must be present too.
|
||||
if form.SourceID != nil || form.LoginName != nil {
|
||||
if form.SourceID == nil || form.LoginName == nil {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "LoginSourceAndLoginName", fmt.Errorf("source_id and login_name must be specified together"))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
authOpts := &user_service.UpdateAuthOptions{
|
||||
LoginSource: optional.FromNonDefault(form.SourceID),
|
||||
LoginName: optional.Some(form.LoginName),
|
||||
LoginSource: optional.FromPtr(form.SourceID),
|
||||
LoginName: optional.FromPtr(form.LoginName),
|
||||
Password: optional.FromNonDefault(form.Password),
|
||||
MustChangePassword: optional.FromPtr(form.MustChangePassword),
|
||||
ProhibitLogin: optional.FromPtr(form.ProhibitLogin),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue