mirror of
https://github.com/pushbits/server.git
synced 2025-06-22 20:37:34 +02:00
Add option to check for weak passwords
This commit is contained in:
parent
ad56422838
commit
b06bd51d21
12 changed files with 141 additions and 15 deletions
|
@ -36,25 +36,35 @@ type CreateUser struct {
|
|||
}
|
||||
|
||||
// NewUser creates a new user.
|
||||
func NewUser(cm *credentials.Manager, name, password string, isAdmin bool, matrixID string) *User {
|
||||
func NewUser(cm *credentials.Manager, name, password string, isAdmin bool, matrixID string) (*User, error) {
|
||||
log.Printf("Creating user %s.\n", name)
|
||||
|
||||
passwordHash, err := cm.CreatePasswordHash(password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &User{
|
||||
Name: name,
|
||||
PasswordHash: cm.CreatePasswordHash(password),
|
||||
PasswordHash: passwordHash,
|
||||
IsAdmin: isAdmin,
|
||||
MatrixID: matrixID,
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
// IntoInternalUser converts a CreateUser into a User.
|
||||
func (u *CreateUser) IntoInternalUser(cm *credentials.Manager) *User {
|
||||
func (u *CreateUser) IntoInternalUser(cm *credentials.Manager) (*User, error) {
|
||||
passwordHash, err := cm.CreatePasswordHash(u.Password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &User{
|
||||
Name: u.Name,
|
||||
PasswordHash: cm.CreatePasswordHash(u.Password),
|
||||
PasswordHash: passwordHash,
|
||||
IsAdmin: u.IsAdmin,
|
||||
MatrixID: u.MatrixID,
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
// IntoExternalUser converts a User into a ExternalUser.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue