@ -93,11 +93,20 @@ func CreateUser(ctx *context.APIContext) {
if ctx . Written ( ) {
if ctx . Written ( ) {
return
return
}
}
if u . LoginType == auth . Plain {
if len ( form . Password ) < setting . MinPasswordLength {
err := errors . New ( "PasswordIsRequired" )
ctx . Error ( http . StatusBadRequest , "PasswordIsRequired" , err )
return
}
if ! password . IsComplexEnough ( form . Password ) {
if ! password . IsComplexEnough ( form . Password ) {
err := errors . New ( "PasswordComplexity" )
err := errors . New ( "PasswordComplexity" )
ctx . Error ( http . StatusBadRequest , "PasswordComplexity" , err )
ctx . Error ( http . StatusBadRequest , "PasswordComplexity" , err )
return
return
}
}
pwned , err := password . IsPwned ( ctx , form . Password )
pwned , err := password . IsPwned ( ctx , form . Password )
if pwned {
if pwned {
if err != nil {
if err != nil {
@ -106,6 +115,7 @@ func CreateUser(ctx *context.APIContext) {
ctx . Error ( http . StatusBadRequest , "PasswordPwned" , errors . New ( "PasswordPwned" ) )
ctx . Error ( http . StatusBadRequest , "PasswordPwned" , errors . New ( "PasswordPwned" ) )
return
return
}
}
}
overwriteDefault := & user_model . CreateUserOverwriteOptions {
overwriteDefault := & user_model . CreateUserOverwriteOptions {
IsActive : util . OptionalBoolTrue ,
IsActive : util . OptionalBoolTrue ,