Skip to content

Commit

Permalink
feat: add customizable generic oidc login button
Browse files Browse the repository at this point in the history
Rebased and modified to reflect project-zot/zot#1691 conclusion

Signed-off-by: Damien Degois <damien@degois.info>
  • Loading branch information
babs authored and raulkele committed Aug 28, 2023
1 parent 96008d6 commit ac84c37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/components/Login/SignIn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Alert from '@mui/material/Alert';
import CircularProgress from '@mui/material/CircularProgress';
import Loading from '../Shared/Loading';

import { GoogleLoginButton, GithubLoginButton, DexLoginButton } from './ThirdPartyLoginComponents';
import { GoogleLoginButton, GithubLoginButton, OIDCLoginButton } from './ThirdPartyLoginComponents';

// styling
import { makeStyles } from '@mui/styles';
Expand Down Expand Up @@ -284,14 +284,15 @@ export default function SignIn({ isLoggedIn, setIsLoggedIn, wrapperSetLoading =
let isGoogle = isObject(authMethods.openid?.providers?.google);
// let isGitlab = isObject(authMethods.openid?.providers?.gitlab);
let isGithub = isObject(authMethods.openid?.providers?.github);
let isDex = isObject(authMethods.openid?.providers?.dex);
let isOIDC = isObject(authMethods.openid?.providers?.oidc);
let oidcName = authMethods.openid?.providers?.oidc?.name;

return (
<Stack direction="column" spacing="1rem" className={classes.thirdPartyLoginContainer}>
{isGithub && <GithubLoginButton handleClick={handleClickExternalLogin} />}
{isGoogle && <GoogleLoginButton handleClick={handleClickExternalLogin} />}
{/* {isGitlab && <GitlabLoginButton handleClick={handleClickExternalLogin} />} */}
{isDex && <DexLoginButton handleClick={handleClickExternalLogin} />}
{isOIDC && <OIDCLoginButton handleClick={handleClickExternalLogin} oidcName={oidcName} />}
</Stack>
);
};
Expand All @@ -308,7 +309,7 @@ export default function SignIn({ isLoggedIn, setIsLoggedIn, wrapperSetLoading =
Sign In
</Typography>
<Typography align="left" className={classes.subtext} variant="body1" gutterBottom>
Welcome back! Please enter your details.
Welcome back! Please login.
</Typography>
{renderThirdPartyLoginMethods()}
{Object.keys(authMethods).length > 1 && <Divider className={classes.divider}>or</Divider>}
Expand Down
9 changes: 5 additions & 4 deletions src/components/Login/ThirdPartyLoginComponents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ function GitlabLoginButton({ handleClick }) {
);
}

function DexLoginButton({ handleClick }) {
function OIDCLoginButton({ handleClick, oidcName }) {
const classes = useStyles();
const loginWithName = oidcName || 'OIDC';

return (
<Button fullWidth variant="contained" className={classes.button} onClick={(e) => handleClick(e, 'dex')}>
Sign in with Dex
<Button fullWidth variant="contained" className={classes.button} onClick={(e) => handleClick(e, 'oidc')}>
Sign in with {loginWithName}
</Button>
);
}

export { GithubLoginButton, GoogleLoginButton, GitlabLoginButton, DexLoginButton };
export { GithubLoginButton, GoogleLoginButton, GitlabLoginButton, OIDCLoginButton };

0 comments on commit ac84c37

Please sign in to comment.