feat: add admin user serializer with accept invitation url

This commit is contained in:
Ali BARIN
2024-09-18 15:25:33 +00:00
committed by Faruk AYDIN
parent b02960a5ec
commit 9299948072
6 changed files with 54 additions and 4 deletions

View File

@@ -180,6 +180,10 @@ class User extends Base {
},
});
static get virtualAttributes() {
return ['acceptInvitationUrl'];
}
get authorizedFlows() {
const conditions = this.can('read', 'Flow');
return conditions.isCreator ? this.$relatedQuery('flows') : Flow.query();
@@ -204,6 +208,10 @@ class User extends Base {
: Execution.query();
}
get acceptInvitationUrl() {
return `${appConfig.webAppUrl}/accept-invitation?token=${this.invitationToken}`;
}
static async authenticate(email, password) {
const user = await User.query().findOne({
email: email?.toLowerCase() || null,
@@ -362,7 +370,6 @@ class User extends Base {
await this.generateInvitationToken();
const jobName = `Invitation Email - ${this.id}`;
const acceptInvitationUrl = `${appConfig.webAppUrl}/accept-invitation?token=${this.invitationToken}`;
const jobPayload = {
email: this.email,
@@ -370,7 +377,7 @@ class User extends Base {
template: 'invitation-instructions',
params: {
fullName: this.fullName,
acceptInvitationUrl,
acceptInvitationUrl: this.acceptInvitationUrl,
},
};