mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-06 23:32:47 +01:00
@@ -11,12 +11,12 @@ import (
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
"github.com/iancoleman/strcase"
|
||||
maut "github.com/jonas-plum/maut/auth"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/database/busdb"
|
||||
"github.com/SecurityBrewery/catalyst/generated/model"
|
||||
"github.com/SecurityBrewery/catalyst/generated/pointer"
|
||||
"github.com/SecurityBrewery/catalyst/generated/time"
|
||||
"github.com/SecurityBrewery/catalyst/role"
|
||||
)
|
||||
|
||||
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_")
|
||||
@@ -35,11 +35,9 @@ func generateKey() string {
|
||||
}
|
||||
|
||||
func toUser(user *model.UserForm, salt, sha256, sha512 *string) *model.User {
|
||||
roles := []string{}
|
||||
roles = append(roles, role.Strings(role.Explodes(user.Roles))...)
|
||||
u := &model.User{
|
||||
Blocked: user.Blocked,
|
||||
Roles: roles,
|
||||
Roles: user.Roles,
|
||||
Salt: salt,
|
||||
Sha256: sha256,
|
||||
Sha512: sha512,
|
||||
@@ -94,7 +92,7 @@ func (db *Database) UserCreate(ctx context.Context, newUser *model.UserForm) (*m
|
||||
var key, salt, sha256Hash, sha512Hash *string
|
||||
if newUser.Apikey {
|
||||
key, sha256Hash = generateAPIKey()
|
||||
} else {
|
||||
} else if newUser.Password != nil {
|
||||
salt, sha512Hash = hashUserPassword(newUser)
|
||||
}
|
||||
|
||||
@@ -111,7 +109,7 @@ func (db *Database) UserCreate(ctx context.Context, newUser *model.UserForm) (*m
|
||||
func (db *Database) UserCreateSetupAPIKey(ctx context.Context, key string) (*model.UserResponse, error) {
|
||||
newUser := &model.UserForm{
|
||||
ID: "setup",
|
||||
Roles: []string{role.Admin},
|
||||
Roles: []string{maut.AdminRole},
|
||||
Apikey: true,
|
||||
Blocked: false,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user