feat: Adds menu item to resend outstanding invites (#3348)

* feat: Adds menu item to resend outstanding invites

* i18n

* snapshots
This commit is contained in:
Tom Moor
2022-04-09 11:34:27 -07:00
committed by GitHub
parent 75a868e5e8
commit 5c1888b0a4
6 changed files with 85 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ Object {
"promote": true,
"read": true,
"readDetails": true,
"resendInvite": true,
"suspend": true,
"update": false,
},
@@ -78,6 +79,7 @@ Object {
"promote": true,
"read": true,
"readDetails": true,
"resendInvite": true,
"suspend": true,
"update": false,
},
@@ -113,6 +115,7 @@ Object {
"promote": true,
"read": true,
"readDetails": true,
"resendInvite": true,
"suspend": true,
"update": false,
},
@@ -148,6 +151,7 @@ Object {
"promote": true,
"read": true,
"readDetails": true,
"resendInvite": true,
"suspend": true,
"update": false,
},
@@ -201,6 +205,7 @@ Object {
"promote": false,
"read": true,
"readDetails": true,
"resendInvite": true,
"suspend": true,
"update": false,
},
@@ -263,6 +268,7 @@ Object {
"promote": false,
"read": true,
"readDetails": true,
"resendInvite": true,
"suspend": true,
"update": false,
},

View File

@@ -3,6 +3,8 @@ import { Op, WhereOptions } from "sequelize";
import userDestroyer from "@server/commands/userDestroyer";
import userInviter from "@server/commands/userInviter";
import userSuspender from "@server/commands/userSuspender";
import InviteEmail from "@server/emails/templates/InviteEmail";
import logger from "@server/logging/logger";
import auth from "@server/middlewares/authentication";
import { Event, User, Team } from "@server/models";
import { can, authorize } from "@server/policies";
@@ -306,6 +308,36 @@ router.post("users.invite", auth(), async (ctx) => {
};
});
router.post("users.resendInvite", auth(), async (ctx) => {
const { id } = ctx.body;
const actor = ctx.state.user;
const user = await User.findByPk(id);
authorize(actor, "resendInvite", user);
await InviteEmail.schedule({
to: user.email,
name: user.name,
actorName: actor.name,
actorEmail: actor.email,
teamName: actor.team.name,
teamUrl: actor.team.url,
});
if (process.env.NODE_ENV === "development") {
logger.info(
"email",
`Sign in immediately: ${
process.env.URL
}/auth/email.callback?token=${user.getEmailSigninToken()}`
);
}
ctx.body = {
success: true,
};
});
router.post("users.delete", auth(), async (ctx) => {
const { confirmation, id } = ctx.body;
assertPresent(confirmation, "confirmation is required");