v2
This commit is contained in:
parent
d2cac44198
commit
d36801edc4
File diff suppressed because one or more lines are too long
@ -43,23 +43,30 @@ class Auth {
|
|||||||
return helpers.jwtSign(data);
|
return helpers.jwtSign(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const newUser = await UsersDBApi.createFromAuth(
|
// Create new user with default role
|
||||||
{
|
const newUser = await UsersDBApi.create(
|
||||||
firstName: email.split('@')[0],
|
{ data: {
|
||||||
password: hashedPassword,
|
firstName: email.split('@')[0],
|
||||||
email: email,
|
password: hashedPassword,
|
||||||
},
|
email: email,
|
||||||
options,
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Send verification email if configured
|
||||||
if (EmailSender.isConfigured) {
|
if (EmailSender.isConfigured) {
|
||||||
await this.sendEmailAddressVerificationEmail(newUser.email, host);
|
await this.sendEmailAddressVerificationEmail(newUser.email, host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch assigned role instance
|
||||||
|
const roleInstance = await newUser.getApp_role();
|
||||||
|
|
||||||
|
// Build JWT payload including role
|
||||||
const data = {
|
const data = {
|
||||||
user: {
|
user: {
|
||||||
id: newUser.id,
|
id: newUser.id,
|
||||||
email: newUser.email,
|
email: newUser.email,
|
||||||
|
role: roleInstance ? roleInstance.name : null,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user