mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-03 07:26:00 +00:00
Update disabled sign up routes
This commit is contained in:
@@ -26,7 +26,13 @@ export const registerSignupRouter = async (server: FastifyZodProvider) => {
|
|||||||
},
|
},
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
const { email } = req.body;
|
const { email } = req.body;
|
||||||
|
|
||||||
const serverCfg = await getServerCfg();
|
const serverCfg = await getServerCfg();
|
||||||
|
if (!serverCfg.allowSignUp) {
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: "Sign up is disabled!"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (serverCfg?.allowedSignUpDomain) {
|
if (serverCfg?.allowedSignUpDomain) {
|
||||||
const domain = email.split("@")[1];
|
const domain = email.split("@")[1];
|
||||||
@@ -62,6 +68,13 @@ export const registerSignupRouter = async (server: FastifyZodProvider) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
|
const serverCfg = await getServerCfg();
|
||||||
|
if (!serverCfg.allowSignUp) {
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: "Sign up is disabled!"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const { token, user } = await server.services.signup.verifyEmailSignup(req.body.email, req.body.code);
|
const { token, user } = await server.services.signup.verifyEmailSignup(req.body.email, req.body.code);
|
||||||
return { message: "Successfuly verified email", token, user };
|
return { message: "Successfuly verified email", token, user };
|
||||||
}
|
}
|
||||||
@@ -104,6 +117,13 @@ export const registerSignupRouter = async (server: FastifyZodProvider) => {
|
|||||||
if (!userAgent) throw new Error("user agent header is required");
|
if (!userAgent) throw new Error("user agent header is required");
|
||||||
const appCfg = getConfig();
|
const appCfg = getConfig();
|
||||||
|
|
||||||
|
const serverCfg = await getServerCfg();
|
||||||
|
if (!serverCfg.allowSignUp) {
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: "Sign up is disabled!"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const { user, accessToken, refreshToken } = await server.services.signup.completeEmailAccountSignup({
|
const { user, accessToken, refreshToken } = await server.services.signup.completeEmailAccountSignup({
|
||||||
...req.body,
|
...req.body,
|
||||||
ip: req.realIp,
|
ip: req.realIp,
|
||||||
@@ -167,6 +187,13 @@ export const registerSignupRouter = async (server: FastifyZodProvider) => {
|
|||||||
if (!userAgent) throw new Error("user agent header is required");
|
if (!userAgent) throw new Error("user agent header is required");
|
||||||
const appCfg = getConfig();
|
const appCfg = getConfig();
|
||||||
|
|
||||||
|
const serverCfg = await getServerCfg();
|
||||||
|
if (!serverCfg.allowSignUp) {
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: "Sign up is disabled!"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const { user, accessToken, refreshToken } = await server.services.signup.completeAccountInvite({
|
const { user, accessToken, refreshToken } = await server.services.signup.completeAccountInvite({
|
||||||
...req.body,
|
...req.body,
|
||||||
ip: req.realIp,
|
ip: req.realIp,
|
||||||
|
|||||||
@@ -270,8 +270,7 @@ export const authLoginServiceFactory = ({ userDAL, tokenService, smtpService }:
|
|||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
// Create a new user based on oAuth
|
// Create a new user based on oAuth
|
||||||
if (!serverCfg?.allowSignUp)
|
if (!serverCfg?.allowSignUp) throw new BadRequestError({ message: "Sign Up disabled", name: "Oauth 2 login" });
|
||||||
throw new BadRequestError({ message: "User signup disabled", name: "Oauth 2 login" });
|
|
||||||
|
|
||||||
if (serverCfg?.allowedSignUpDomain) {
|
if (serverCfg?.allowedSignUpDomain) {
|
||||||
const domain = email.split("@")[1];
|
const domain = email.split("@")[1];
|
||||||
|
|||||||
Reference in New Issue
Block a user