mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-04 01:55:10 +02:00
improve email formatting and invite flow for new users
This commit is contained in:
parent
d244d6003b
commit
d447de9e8a
15 changed files with 107 additions and 89 deletions
|
@ -84,6 +84,15 @@ export async function signup(
|
|||
createHttpError(HttpCode.BAD_REQUEST, "Invite does not exist")
|
||||
);
|
||||
}
|
||||
|
||||
if (existingInvite.email !== email) {
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.BAD_REQUEST,
|
||||
"Invite is not for this user"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -137,7 +137,7 @@ authenticated.post(
|
|||
verifyUserHasAction(ActionsEnum.inviteUser),
|
||||
user.inviteUser
|
||||
); // maybe make this /invite/create instead
|
||||
authenticated.post("/invite/accept", user.acceptInvite);
|
||||
unauthenticated.post("/invite/accept", user.acceptInvite); // this is supposed to be unauthenticated
|
||||
|
||||
authenticated.get(
|
||||
"/resource/:resourceId/roles",
|
||||
|
|
|
@ -12,6 +12,7 @@ import { fromError } from "zod-validation-error";
|
|||
import { isWithinExpirationDate } from "oslo";
|
||||
import { verifyPassword } from "@server/auth/password";
|
||||
import { checkValidInvite } from "@server/auth/checkValidInvite";
|
||||
import { verifySession } from "@server/auth";
|
||||
|
||||
const acceptInviteBodySchema = z
|
||||
.object({
|
||||
|
@ -72,7 +73,9 @@ export async function acceptInvite(
|
|||
);
|
||||
}
|
||||
|
||||
if (req.user && req.user.email !== existingInvite.email) {
|
||||
const { user, session } = await verifySession(req);
|
||||
|
||||
if (user && user.email !== existingInvite.email) {
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.BAD_REQUEST,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue