Skip to content

Commit

Permalink
Net 1227 v2 (#3075)
Browse files Browse the repository at this point in the history
* add list roles to pro and ce

* if not pro set user role to admin

* validate update user

* add separate validation check for password on update
  • Loading branch information
abhishek9686 committed Aug 27, 2024
1 parent a4d528e commit d532060
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions logic/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ func UpdateUser(userchange, user *models.User) (*models.User, error) {
user.UserName = userchange.UserName
}
if userchange.Password != "" {
if len(userchange.Password) < 5 {
return &models.User{}, errors.New("password requires min 5 characters")
}
// encrypt that password so we never see it again
hash, err := bcrypt.GenerateFromPassword([]byte(userchange.Password), 5)

Expand All @@ -306,8 +309,11 @@ func UpdateUser(userchange, user *models.User) (*models.User, error) {
}
user.UserGroups = userchange.UserGroups
user.NetworkRoles = userchange.NetworkRoles

if err := database.DeleteRecord(database.USERS_TABLE_NAME, queryUser); err != nil {
err = ValidateUser(user)
if err != nil {
return &models.User{}, err
}
if err = database.DeleteRecord(database.USERS_TABLE_NAME, queryUser); err != nil {
return &models.User{}, err
}
data, err := json.Marshal(&user)
Expand Down

0 comments on commit d532060

Please sign in to comment.