Skip to content

feat: add empty state for SSO auth methods #9818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: restrict access to full auth in oidc functions
  • Loading branch information
Parkreiner committed Sep 21, 2023
commit b6b787b63f7aa6b52bd3c8c76ad92a848d72bb4e
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import KeyIcon from "@mui/icons-material/VpnKey";
import Button from "@mui/material/Button";
import Typography from "@mui/material/Typography";
import { convertToOAUTH } from "api/api";
import { AuthMethods, LoginType, UserLoginType } from "api/typesGenerated";
import {
AuthMethods,
LoginType,
OIDCAuthMethod,
UserLoginType,
} from "api/typesGenerated";
import { Stack } from "components/Stack/Stack";
import { useMutation } from "@tanstack/react-query";
import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog";
Expand Down Expand Up @@ -133,10 +138,10 @@ export const SingleSignOnSection = ({
size="large"
fullWidth
disabled={isUpdating}
startIcon={<OIDCIcon authMethods={authMethods} />}
startIcon={<OIDCIcon oidcAuth={authMethods.oidc} />}
onClick={() => openConfirmation("oidc")}
>
{getOIDCLabel(authMethods)}
{getOIDCLabel(authMethods.oidc)}
</Button>
)}
</>
Expand Down Expand Up @@ -164,14 +169,14 @@ export const SingleSignOnSection = ({
<strong>
{userLoginType.login_type === "github"
? "GitHub"
: getOIDCLabel(authMethods)}
: getOIDCLabel(authMethods.oidc)}
</strong>
</span>
<Box sx={{ ml: "auto", lineHeight: 1 }}>
{userLoginType.login_type === "github" ? (
<GitHubIcon sx={{ width: 16, height: 16 }} />
) : (
<OIDCIcon authMethods={authMethods} />
<OIDCIcon oidcAuth={authMethods.oidc} />
)}
</Box>
</Box>
Expand All @@ -190,21 +195,23 @@ export const SingleSignOnSection = ({
);
};

const OIDCIcon = ({ authMethods }: { authMethods: AuthMethods }) => {
return authMethods.oidc.iconUrl ? (
const OIDCIcon = ({ oidcAuth }: { oidcAuth: OIDCAuthMethod }) => {
if (!oidcAuth.iconUrl) {
return <KeyIcon sx={{ width: 16, height: 16 }} />;
}

return (
<Box
component="img"
alt="Open ID Connect icon"
src={authMethods.oidc.iconUrl}
src={oidcAuth.iconUrl}
sx={{ width: 16, height: 16 }}
/>
) : (
<KeyIcon sx={{ width: 16, height: 16 }} />
);
};

const getOIDCLabel = (authMethods: AuthMethods) => {
return authMethods.oidc.signInText || "OpenID Connect";
const getOIDCLabel = (oidcAuth: OIDCAuthMethod) => {
return oidcAuth.signInText || "OpenID Connect";
};

const ConfirmLoginTypeChangeModal = ({
Expand Down