feat(onboarding): added signup disable for sso and post hog event on admin initalization

pull/1171/head
Akhil Mohan 6 months ago
parent 9fbf01c19e
commit 4aacbed28b

@ -4,6 +4,7 @@ import { getServerConfig, updateServerConfig as setServerConfig } from "../../co
import { initializeDefaultOrg, issueAuthTokens } from "../../helpers";
import { validateRequest } from "../../helpers/validation";
import { User } from "../../models";
import { TelemetryService } from "../../services";
import { BadRequestError, UnauthorizedRequestError } from "../../utils/errors";
import * as reqValidator from "../../validation/admin";
@ -71,6 +72,18 @@ export const adminSignUp = async (req: Request, res: Response) => {
const token = tokens.token;
const postHogClient = await TelemetryService.getPostHogClient();
if (postHogClient) {
postHogClient.capture({
event: "admin initialization",
properties: {
email: user.email,
lastName,
firstName
}
});
}
// store (refresh) token in httpOnly cookie
res.cookie("jid", tokens.refreshToken, {
httpOnly: true,

@ -5,7 +5,6 @@ import { createToken } from "../../helpers/auth";
import { BadRequestError } from "../../utils/errors";
import {
getAuthSecret,
getInviteOnlySignup,
getJwtSignupLifetime,
getSmtpConfigured
} from "../../config";
@ -68,7 +67,6 @@ export const verifyEmailSignup = async (req: Request, res: Response) => {
});
}
if (await getInviteOnlySignup()) {
// Only one user can create an account without being invited. The rest need to be invited in order to make an account
const userCount = await User.countDocuments({});
if (userCount != 0) {
@ -76,7 +74,6 @@ export const verifyEmailSignup = async (req: Request, res: Response) => {
message: "New user sign ups are not allowed at this time. You must be invited to sign up."
});
}
}
// verify email
if (await getSmtpConfigured()) {

@ -1,10 +1,8 @@
import {
AuthMethod,
User
} from "../../../models";
import { AuthMethod, User } from "../../../models";
import { createToken } from "../../../helpers/auth";
import { AuthTokenType } from "../../../variables";
import { getAuthSecret, getJwtProviderAuthLifetime } from "../../../config";
import { getServerConfig } from "../../../config/serverConfig";
interface SSOUserTokenFlowParams {
email: string;
@ -25,6 +23,9 @@ export const handleSSOUserTokenFlow = async ({
email
}).select("+publicKey");
const serverCfg = getServerConfig();
if (!user && !serverCfg.allowSignUp) throw new Error("User signup disabled");
if (!user) {
user = await new User({
email,
@ -50,13 +51,15 @@ export const handleSSOUserTokenFlow = async ({
authMethod,
isUserCompleted,
isLinkingRequired,
...(callbackPort ? {
...(callbackPort
? {
callbackPort
} : {})
}
: {})
},
expiresIn: await getJwtProviderAuthLifetime(),
secret: await getAuthSecret(),
secret: await getAuthSecret()
});
return { isUserCompleted, providerAuthToken };
}
};

@ -31,9 +31,9 @@ export const AdminDashboardPage = () => {
return (
<div className="container mx-auto max-w-7xl pb-12 text-white dark:[color-scheme:dark]">
<div className="mb-8">
<div className="mx-4 mb-4 mt-6 flex flex-col items-start justify-between px-2 text-xl">
<div className="mb-4 mt-6 flex flex-col items-start justify-between text-xl">
<h1 className="text-3xl font-semibold">Admin Dashboard</h1>
<p className="text-base text-bunker-300">Manage your Infisical.</p>
<p className="text-base text-bunker-300">Manage your Infisical</p>
</div>
</div>
{isUserLoading || isNotAllowed ? (

Loading…
Cancel
Save