-
Notifications
You must be signed in to change notification settings - Fork 916
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
feat: add oidc support #1103
feat: add oidc support #1103
Changes from 2 commits
e0440fd
bd4a1c4
788c626
d8d0734
70eeb1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -52,9 +52,15 @@ export type SignUpFormProps = { | |||||||||||||||||||||||||||||||||||||||||||||||||
className?: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||
initialEmail?: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||
isGoogleSSOEnabled?: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||
isOIDCSSOEnabled?: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
export const SignUpForm = ({ className, initialEmail, isGoogleSSOEnabled }: SignUpFormProps) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
export const SignUpForm = ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
className, | ||||||||||||||||||||||||||||||||||||||||||||||||||
initialEmail, | ||||||||||||||||||||||||||||||||||||||||||||||||||
isGoogleSSOEnabled, | ||||||||||||||||||||||||||||||||||||||||||||||||||
isOIDCSSOEnabled, | ||||||||||||||||||||||||||||||||||||||||||||||||||
}: SignUpFormProps) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
const { toast } = useToast(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
const analytics = useAnalytics(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
const router = useRouter(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -121,6 +127,19 @@ export const SignUpForm = ({ className, initialEmail, isGoogleSSOEnabled }: Sign | |||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
const onSignUpWithOIDCClick = async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||||
await signIn('google', { callbackUrl: SIGN_UP_REDIRECT_PATH }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} catch (err) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
toast({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
title: 'An unknown error occurred', | ||||||||||||||||||||||||||||||||||||||||||||||||||
description: | ||||||||||||||||||||||||||||||||||||||||||||||||||
'We encountered an unknown error while attempting to sign you Up. Please try again later.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
variant: 'destructive', | ||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace the incorrect provider key in - await signIn('google', { callbackUrl: SIGN_UP_REDIRECT_PATH });
+ await signIn('oidc', { callbackUrl: SIGN_UP_REDIRECT_PATH }); The Committable suggestion
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has been fixed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tankerkiller125, thank you for the update and for fixing the issue with the OIDC sign-in provider key. If there's anything else you need help with, feel free to ask! If you found this review helpful, would you consider giving us a shout-out on X? |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
<Form {...form}> | ||||||||||||||||||||||||||||||||||||||||||||||||||
<form | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -221,6 +240,28 @@ export const SignUpForm = ({ className, initialEmail, isGoogleSSOEnabled }: Sign | |||||||||||||||||||||||||||||||||||||||||||||||||
</Button> | ||||||||||||||||||||||||||||||||||||||||||||||||||
</> | ||||||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
{isOIDCSSOEnabled && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
<> | ||||||||||||||||||||||||||||||||||||||||||||||||||
<div className="relative flex items-center justify-center gap-x-4 py-2 text-xs uppercase"> | ||||||||||||||||||||||||||||||||||||||||||||||||||
<div className="bg-border h-px flex-1" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
<span className="text-muted-foreground bg-transparent">Or</span> | ||||||||||||||||||||||||||||||||||||||||||||||||||
<div className="bg-border h-px flex-1" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
<Button | ||||||||||||||||||||||||||||||||||||||||||||||||||
type="button" | ||||||||||||||||||||||||||||||||||||||||||||||||||
size="lg" | ||||||||||||||||||||||||||||||||||||||||||||||||||
variant={'outline'} | ||||||||||||||||||||||||||||||||||||||||||||||||||
className="bg-background text-muted-foreground border" | ||||||||||||||||||||||||||||||||||||||||||||||||||
disabled={isSubmitting} | ||||||||||||||||||||||||||||||||||||||||||||||||||
onClick={onSignUpWithOIDCClick} | ||||||||||||||||||||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||||||||||||||||||||
<FcGoogle className="mr-2 h-5 w-5" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||
Sign Up with OIDC | ||||||||||||||||||||||||||||||||||||||||||||||||||
</Button> | ||||||||||||||||||||||||||||||||||||||||||||||||||
</> | ||||||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||||||
</form> | ||||||||||||||||||||||||||||||||||||||||||||||||||
</Form> | ||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -10,6 +10,7 @@ import { zodResolver } from '@hookform/resolvers/zod'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { AnimatePresence, motion } from 'framer-motion'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { signIn } from 'next-auth/react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { useForm } from 'react-hook-form'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { FaIdCardClip } from 'react-icons/fa6'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { FcGoogle } from 'react-icons/fc'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { z } from 'zod'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -73,12 +74,14 @@ export type SignUpFormV2Props = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
className?: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
initialEmail?: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
isGoogleSSOEnabled?: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
isOIDCSSOEnabled?: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export const SignUpFormV2 = ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
className, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
initialEmail, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
isGoogleSSOEnabled, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
isOIDCSSOEnabled, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}: SignUpFormV2Props) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const { toast } = useToast(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const analytics = useAnalytics(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -179,6 +182,19 @@ export const SignUpFormV2 = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const onSignUpWithOIDCClick = async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await signIn('oidc', { callbackUrl: SIGN_UP_REDIRECT_PATH }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} catch (err) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
toast({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
title: 'An unknown error occurred', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'We encountered an unknown error while attempting to sign you Up. Please try again later.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
variant: 'destructive', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div className={cn('flex justify-center gap-x-12', className)}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div className="border-border relative hidden flex-1 overflow-hidden rounded-xl border xl:flex"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -255,7 +271,7 @@ export const SignUpFormV2 = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<fieldset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
className={cn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'flex h-[550px] w-full flex-col gap-y-4', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
isGoogleSSOEnabled && 'h-[650px]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(isGoogleSSOEnabled || isOIDCSSOEnabled) && 'h-[650px]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
disabled={isSubmitting} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -323,14 +339,18 @@ export const SignUpFormV2 = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{isGoogleSSOEnabled && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{(isGoogleSSOEnabled || isOIDCSSOEnabled) && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div className="relative flex items-center justify-center gap-x-4 py-2 text-xs uppercase"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div className="bg-border h-px flex-1" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<span className="text-muted-foreground bg-transparent">Or</span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div className="bg-border h-px flex-1" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{isGoogleSSOEnabled && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<Button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type="button" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
size="lg" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -345,6 +365,22 @@ export const SignUpFormV2 = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{isOIDCSSOEnabled && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<Button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type="button" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
size="lg" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
variant={'outline'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
className="bg-background text-muted-foreground border" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
disabled={isSubmitting} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
onClick={onSignUpWithOIDCClick} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<FaIdCardClip className="mr-2 h-5 w-5" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sign Up with OIDC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</Button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+368
to
+382
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The implementation of the OIDC sign-up button is correct. However, consider adding an aria-label to the button for better accessibility. - <Button type="button" size="lg" variant={'outline'} className="bg-background text-muted-foreground border" disabled={isSubmitting} onClick={onSignUpWithOIDCClick}>
+ <Button type="button" size="lg" variant={'outline'} className="bg-background text-muted-foreground border" disabled={isSubmitting} onClick={onSignUpWithOIDCClick} aria-label="Sign up with OIDC"> Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<p className="text-muted-foreground mt-4 text-sm"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Already have an account?{' '} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<Link href="/signin" className="text-documenso-700 duration-200 hover:opacity-70"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TYPE "IdentityProvider" ADD VALUE IF NOT EXISTS 'OIDC'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ datasource db { | |
enum IdentityProvider { | ||
DOCUMENSO | ||
OIDC | ||
} | ||
|
||
enum Role { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct the provider key in the
signIn
function for OIDC.The
onSignInWithOIDCClick
function should use 'oidc' as the provider key for the OIDC sign-in to match the intended authentication method.Committable suggestion