-
Notifications
You must be signed in to change notification settings - Fork 915
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 all 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- AlterTable | ||
ALTER TABLE "Account" ADD COLUMN "created_at" INTEGER, | ||
ADD COLUMN "ext_expires_in" INTEGER; |
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