Skip to content

Commit 4d14927

Browse files
committed
feat: add password validation to CreateUser function
- Add validation for password requirement in CreateUser function Signed-off-by: appleboy <[email protected]>
1 parent cb31e62 commit 4d14927

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

routers/api/v1/admin/user.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ func CreateUser(ctx *context.APIContext) {
9393
if ctx.Written() {
9494
return
9595
}
96+
97+
if u.LoginType == auth.Plain && len(form.Password) == 0 {
98+
err := errors.New("PasswordIsRequired")
99+
ctx.Error(http.StatusBadRequest, "PasswordIsRequired", err)
100+
return
101+
}
102+
96103
if !password.IsComplexEnough(form.Password) {
97104
err := errors.New("PasswordComplexity")
98105
ctx.Error(http.StatusBadRequest, "PasswordComplexity", err)

0 commit comments

Comments
 (0)