fix validation, derrive teamID and Roles from tokens
This commit is contained in:
1 parent
78b920aaf6
commit
5152336591
6 files changed
+45
-15
No files matched your search
@@ -87,10 +87,10 @@ class UserService {
|
||||
const superAdminExists = await this.usersRepository.findSuperAdmin();
|
||||
if (superAdminExists) {
|
||||
const invite = await this.invitesRepository.findByTokenAndDelete(inviteToken);
|
||||
user.role = invite.role;
|
||||
user.role = invite.role ?? ["user"];
|
||||
user.teamId = invite.teamId;
|
||||
user.email = invite.email;
|
||||
} else {
|
||||
console.log("WHITFUSKALG");
|
||||
// This is the first account, create JWT secret to use if one is not supplied by env
|
||||
const jwtSecret = this.crypto.randomBytes(64).toString("hex");
|
||||
await this.settingsRepository.update({ jwtSecret });
|
||||
@@ -100,6 +100,7 @@ class UserService {
|
||||
}
|
||||
const team = await this.teamsRepository.create(user.email);
|
||||
user.teamId = team.id;
|
||||
user.role = ["superadmin"];
|
||||
}
|
||||
|
||||
const newUser = await this.usersRepository.create({ ...user }, file);
|
||||
|
||||
Reference in new issue
Block a user