get invite role and teamId from invite instead of client
This commit is contained in:
1 parent
d5adf7a2be
commit
c2ffdd1d62
1 file changed
+4
-2
@@ -68,11 +68,13 @@ class AuthController {
|
|||||||
}
|
}
|
||||||
// Create a new user
|
// Create a new user
|
||||||
try {
|
try {
|
||||||
const { inviteToken } = req.body;
|
const user = req.body;
|
||||||
// If superAdmin exists, a token should be attached to all further register requests
|
// If superAdmin exists, a token should be attached to all further register requests
|
||||||
const superAdminExists = await this.db.checkSuperadmin(req, res);
|
const superAdminExists = await this.db.checkSuperadmin(req, res);
|
||||||
if (superAdminExists) {
|
if (superAdminExists) {
|
||||||
await this.db.getInviteTokenAndDelete(inviteToken);
|
const invitedUser = await this.db.getInviteTokenAndDelete(user.inviteToken);
|
||||||
|
user.role = invitedUser.role;
|
||||||
|
user.teamId = invitedUser.teamId;
|
||||||
} else {
|
} else {
|
||||||
// This is the first account, create JWT secret to use if one is not supplied by env
|
// This is the first account, create JWT secret to use if one is not supplied by env
|
||||||
const jwtSecret = crypto.randomBytes(64).toString("hex");
|
const jwtSecret = crypto.randomBytes(64).toString("hex");
|
||||||
|
|||||||
Reference in new issue
Block a user