Skip to content

Commit

Permalink
Fix empty membership groups for first user properly
Browse files Browse the repository at this point in the history
  • Loading branch information
NHAS committed Jun 10, 2024
1 parent 00be04e commit ab97da5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/data/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,13 @@ func CreateUserDataAccount(username string) (UserModel, error) {
}
b, _ := json.Marshal(&newUser)

emptyGroups := []string{}

groups, _ := json.Marshal(emptyGroups)

txn := etcd.Txn(context.Background())
txn.If(clientv3util.KeyMissing("users-" + username + "-"))
txn.Then(clientv3.OpPut(UsersPrefix+username+"-", string(b)), clientv3.OpPut(MembershipKey+"-"+username, ""))
txn.Then(clientv3.OpPut(UsersPrefix+username+"-", string(b)), clientv3.OpPut(MembershipKey+"-"+username, string(groups)))

res, err := txn.Commit()
if err != nil {
Expand Down

0 comments on commit ab97da5

Please sign in to comment.