mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: redirect unauthorized git users to login screen (#10995)
* fix: redirect to login screen if unauthorized git user * consolidated language * fix redirect
This commit is contained in:
@@ -24,7 +24,7 @@ export const LoginPageView: FC<LoginPageViewProps> = ({
|
||||
const redirectTo = retrieveRedirect(location.search);
|
||||
// This allows messages to be displayed at the top of the sign in form.
|
||||
// Helpful for any redirects that want to inform the user of something.
|
||||
const info = new URLSearchParams(location.search).get("info") || undefined;
|
||||
const message = new URLSearchParams(location.search).get("message");
|
||||
const applicationName = getApplicationName();
|
||||
const logoURL = getLogoURL();
|
||||
const applicationLogo = logoURL ? (
|
||||
@@ -52,7 +52,7 @@ export const LoginPageView: FC<LoginPageViewProps> = ({
|
||||
redirectTo={redirectTo}
|
||||
isSigningIn={isSigningIn}
|
||||
error={error}
|
||||
info={info}
|
||||
message={message}
|
||||
onSubmit={onSignIn}
|
||||
/>
|
||||
<footer css={styles.footer}>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type Interpolation, type Theme } from "@emotion/react";
|
||||
import { type FC } from "react";
|
||||
import { ReactNode, type FC } from "react";
|
||||
import type { AuthMethods } from "api/typesGenerated";
|
||||
import { PasswordSignInForm } from "./PasswordSignInForm";
|
||||
import { OAuthSignInForm } from "./OAuthSignInForm";
|
||||
@@ -63,7 +63,7 @@ export interface SignInFormProps {
|
||||
isSigningIn: boolean;
|
||||
redirectTo: string;
|
||||
error?: unknown;
|
||||
info?: string;
|
||||
message?: ReactNode;
|
||||
authMethods?: AuthMethods;
|
||||
onSubmit: (credentials: { email: string; password: string }) => void;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ export const SignInForm: FC<React.PropsWithChildren<SignInFormProps>> = ({
|
||||
redirectTo,
|
||||
isSigningIn,
|
||||
error,
|
||||
info,
|
||||
message,
|
||||
onSubmit,
|
||||
}) => {
|
||||
const oAuthEnabled = Boolean(
|
||||
@@ -91,9 +91,9 @@ export const SignInForm: FC<React.PropsWithChildren<SignInFormProps>> = ({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{Boolean(info) && Boolean(error) && (
|
||||
{message && (
|
||||
<div css={styles.alert}>
|
||||
<Alert severity="info">{info}</Alert>
|
||||
<Alert severity="info">{message}</Alert>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ export const useSingleSignOnSection = () => {
|
||||
// The redirect on success should be back to the login page with a nice message.
|
||||
// The user should be logged out if this worked.
|
||||
encodeURIComponent(
|
||||
`/login?info=Login type has been changed to ${loginTypeMsg}. Log in again using the new method.`,
|
||||
`/login?message=Login type has been changed to ${loginTypeMsg}. Log in again using the new method.`,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user