mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
Allow to pass custom URL for user invitation (#3972)
* Allow to pass custom URL for invitation to enable verification of user's email on custom Frond-End page (other than Directus Admin page). * Update api/src/services/users.ts Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com> * Update api/src/services/users.ts Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com> * Update api/src/services/users.ts Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com> Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -215,7 +215,7 @@ router.post(
|
||||
accountability: req.accountability,
|
||||
schema: req.schema,
|
||||
});
|
||||
await service.inviteUser(req.body.email, req.body.role);
|
||||
await service.inviteUser(req.body.email, req.body.role, req.body.invite_url || null);
|
||||
return next();
|
||||
}),
|
||||
respond
|
||||
|
||||
@@ -78,7 +78,7 @@ export class UsersService extends ItemsService {
|
||||
return key;
|
||||
}
|
||||
|
||||
async inviteUser(email: string | string[], role: string) {
|
||||
async inviteUser(email: string | string[], role: string, url: string | null) {
|
||||
const emails = toArray(email);
|
||||
|
||||
for (const email of emails) {
|
||||
@@ -86,7 +86,8 @@ export class UsersService extends ItemsService {
|
||||
|
||||
const payload = { email, scope: 'invite' };
|
||||
const token = jwt.sign(payload, env.SECRET as string, { expiresIn: '7d' });
|
||||
const acceptURL = env.PUBLIC_URL + '/admin/accept-invite?token=' + token;
|
||||
const inviteURL = url ?? env.PUBLIC_URL + '/admin/accept-invite';
|
||||
const acceptURL = inviteURL + '?token=' + token;
|
||||
|
||||
await sendInviteMail(email, acceptURL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user