Skip to content

Commit 57acac0

Browse files
authored
fix (@jitsucom/console): signin page markup + oidc configuration handling (#1167)
* update html * add oidcLoginEnabled * remove unused prop
1 parent a7419db commit 57acac0

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

webapps/console/lib/nextauth.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const crypto = require("crypto");
1616
const log = getServerLog("auth");
1717

1818
export const githubLoginEnabled = !!process.env.GITHUB_CLIENT_ID;
19+
export const oidcLoginEnabled = !!process.env.AUTH_OIDC_PROVIDER;
1920
export const oidcLoginConfig = ParseJSONConfigFromEnv(process.env.AUTH_OIDC_PROVIDER as string);
2021
export const credentialsLoginEnabled =
2122
isTruish(process.env.ENABLE_CREDENTIALS_LOGIN) || !!(process.env.SEED_USER_EMAIL && process.env.SEED_USER_PASSWORD);

webapps/console/pages/signin.tsx

+13-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import React, { useState } from "react";
99
import { feedbackError } from "../lib/ui";
1010
import { useRouter } from "next/router";
1111
import { branding } from "../lib/branding";
12-
import { credentialsLoginEnabled, githubLoginEnabled, oidcLoginConfig } from "../lib/nextauth.config";
12+
import { credentialsLoginEnabled, githubLoginEnabled, oidcLoginEnabled } from "../lib/nextauth.config";
1313
import { useQuery } from "@tanstack/react-query";
1414

1515
function JitsuLogo() {
@@ -21,7 +21,7 @@ function JitsuLogo() {
2121
);
2222
}
2323

24-
function CredentialsForm({}) {
24+
function CredentialsForm() {
2525
const lastUsedLogin = localStorage.getItem("last-used-login-email") || undefined;
2626
const { data, isLoading, error } = useQuery(["next-auth-csrfToken"], async () => {
2727
return {
@@ -130,12 +130,12 @@ const NextAuthSignInPage = ({ csrfToken, providers: { github, oidc, credentials
130130
return (
131131
<div className="w-screen h-screen flex flex-col items-center justify-center">
132132
<AlertTriangle className="w-32 h-32 text-error" />
133-
<div className="mt-3 text-textLight text-center">
133+
<p className="mt-3 text-textLight text-center">
134134
This page should not be used if Firebase authorization is enabled. Please proceed to a{" "}
135135
<Link href="/" className="underline text-primary">
136136
main page of the app
137137
</Link>
138-
</div>
138+
</p>
139139
</div>
140140
);
141141
}
@@ -144,34 +144,34 @@ const NextAuthSignInPage = ({ csrfToken, providers: { github, oidc, credentials
144144
<div className="space-y-2 flex justify-center h-16">
145145
<JitsuLogo />
146146
</div>
147-
<div className={"flex flex-col gap-1.5"}>
147+
<div className="flex flex-col gap-1.5">
148148
{credentials.enabled && <CredentialsForm />}
149149
{credentials.enabled && (github.enabled || oidc.enabled) && <hr className="my-4" />}
150150
{github.enabled && <GitHubSignIn />}
151151
{oidc.enabled && <OIDCSignIn />}
152152
</div>
153153
{router.query.error && (
154-
<div className="text-error">
154+
<p className="text-error">
155155
Something went wrong. Please try again. Error code: <code>{router.query.error}</code>
156-
</div>
156+
</p>
157157
)}
158158
{!app.disableSignup && (github.enabled || oidc.enabled) && (
159-
<div className="text-center text-textLight text-xs">
159+
<p className="text-center text-textLight text-xs">
160160
Automatic signup is enabled for this instance. Sign in with github and if you don't have an account, a new
161161
account will be created automatically. This account won't have any access to pre-existing project unless the
162162
access is explicitly granted
163-
</div>
163+
</p>
164164
)}
165165
</div>
166166
);
167167
};
168168

169-
export async function getServerSideProps(context) {
169+
export async function getServerSideProps() {
170170
if (process.env.FIREBASE_AUTH) {
171171
throw new Error(`Firebase auth is enabled. This page should not be used.`);
172172
}
173-
if (!githubLoginEnabled && !credentialsLoginEnabled && !oidcLoginConfig) {
174-
throw new Error(`No auth providers are enabled found. Available providers: github, credentials`);
173+
if (!githubLoginEnabled && !credentialsLoginEnabled && !oidcLoginEnabled) {
174+
throw new Error(`No auth providers are enabled found. Available providers: github, credentials, OIDC`);
175175
}
176176
return {
177177
props: {
@@ -184,7 +184,7 @@ export async function getServerSideProps(context) {
184184
enabled: githubLoginEnabled,
185185
},
186186
oidc: {
187-
enabled: !!oidcLoginConfig,
187+
enabled: oidcLoginEnabled,
188188
},
189189
},
190190
publicPage: true,

0 commit comments

Comments
 (0)