Add a password policy for distillery users
This commit is contained in:
parent
ab9998881b
commit
6f257bd27f
9 changed files with 185 additions and 76 deletions
|
|
@ -135,6 +135,11 @@ func (du disUser) runDelete(context wisski_distillery.Context) error {
|
|||
return user.Delete(context.Context)
|
||||
}
|
||||
|
||||
var errPasswordPolicy = exit.Error{
|
||||
Message: "password policy failed: %s",
|
||||
ExitCode: exit.ExitGeneric,
|
||||
}
|
||||
|
||||
func (du disUser) runSetPassword(context wisski_distillery.Context) error {
|
||||
user, err := context.Environment.Auth().User(context.Context, du.Positionals.User)
|
||||
if err != nil {
|
||||
|
|
@ -160,8 +165,8 @@ func (du disUser) runSetPassword(context wisski_distillery.Context) error {
|
|||
if passwd != passwd1 {
|
||||
return errPasswordsNotIdentical
|
||||
}
|
||||
if len(passwd) == 0 {
|
||||
return errPasswordsNotIdentical
|
||||
if err := user.CheckPasswordPolicy(passwd); err != nil {
|
||||
return errPasswordPolicy.WithMessageF(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue