mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-03 17:18:36 +00:00
feat: add roles, activation, superuser fields on user (#38)
This commit is contained in:
parent
a6d2fd45df
commit
0c90b05dca
17 changed files with 705 additions and 12 deletions
|
@ -49,18 +49,21 @@ func (svc *UserService) RegisterUser(ctx context.Context, data UserRegistration)
|
|||
Msg("Registering new user")
|
||||
|
||||
var (
|
||||
err error
|
||||
group repo.Group
|
||||
token repo.GroupInvitation
|
||||
err error
|
||||
group repo.Group
|
||||
token repo.GroupInvitation
|
||||
isOwner = false
|
||||
)
|
||||
|
||||
if data.GroupToken == "" {
|
||||
switch data.GroupToken {
|
||||
case "":
|
||||
isOwner = true
|
||||
group, err = svc.repos.Groups.GroupCreate(ctx, "Home")
|
||||
if err != nil {
|
||||
log.Err(err).Msg("Failed to create group")
|
||||
return repo.UserOut{}, err
|
||||
}
|
||||
} else {
|
||||
default:
|
||||
token, err = svc.repos.Groups.InvitationGet(ctx, hasher.HashToken(data.GroupToken))
|
||||
if err != nil {
|
||||
log.Err(err).Msg("Failed to get invitation token")
|
||||
|
@ -76,6 +79,7 @@ func (svc *UserService) RegisterUser(ctx context.Context, data UserRegistration)
|
|||
Password: hashed,
|
||||
IsSuperuser: false,
|
||||
GroupID: group.ID,
|
||||
IsOwner: isOwner,
|
||||
}
|
||||
|
||||
usr, err := svc.repos.Users.Create(ctx, usrCreate)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue