-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate authentication using Clerk (#15)
https://clerk.com/docs/custom-flows/oauth-connections Currently support `Github`, `Google`, and `Apple`.
- Loading branch information
Showing
61 changed files
with
2,649 additions
and
1,180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
DATABASE_URL= | ||
supabaseUrl= | ||
supabaseAnonKey= | ||
googleClientIdAndroid= | ||
googleClientIdIOS= | ||
googleClientIdWeb= | ||
expoProjectId= | ||
expoProjectId= | ||
EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,5 +46,6 @@ | |
"Pressable", | ||
"Pretendard", | ||
"svgs" | ||
] | ||
], | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import {Redirect, Stack} from 'expo-router'; | ||
import {useRecoilValue} from 'recoil'; | ||
import {authRecoilState} from '../../src/recoil/atoms'; | ||
import {Stack} from 'expo-router/stack'; | ||
import {useDooboo} from 'dooboo-ui'; | ||
import {Redirect} from 'expo-router'; | ||
import {useAuth} from '@clerk/clerk-expo'; | ||
|
||
export default function AuthLayout() { | ||
const {authId} = useRecoilValue(authRecoilState); | ||
const {theme} = useDooboo(); | ||
const {isSignedIn} = useAuth(); | ||
|
||
if (authId) { | ||
return <Redirect href={'/'} />; | ||
if (isSignedIn) { | ||
return <Redirect href={'/(tabs)'} />; | ||
} | ||
|
||
return <Stack />; | ||
return ( | ||
<Stack | ||
initialRouteName="intro" | ||
screenOptions={{ | ||
headerStyle: {backgroundColor: theme.bg.basic}, | ||
headerTintColor: theme.text.label, | ||
headerTitleStyle: { | ||
fontWeight: 'bold', | ||
color: theme.text.basic, | ||
}, | ||
}} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
import {Image, ScrollView, View} from 'react-native'; | ||
import * as WebBrowser from 'expo-web-browser'; | ||
|
||
import styled, {css} from '@emotion/native'; | ||
|
||
import {Typography, useDooboo} from 'dooboo-ui'; | ||
import {Stack, useRouter} from 'expo-router'; | ||
|
||
import {IMG_CROSSPLATFORMS, IC_ICON} from '../../src/icons'; | ||
import {t} from '../../src/STRINGS'; | ||
import {useSafeAreaInsets} from 'react-native-safe-area-context'; | ||
import ButtonSocialSignIn from '../../src/components/uis/ButtonSocialSignIn'; | ||
import {useWarmUpBrowser} from '../../src/hooks/useWarmUpBrowser'; | ||
|
||
WebBrowser.maybeCompleteAuthSession(); | ||
|
||
const Container = styled.View` | ||
flex: 1; | ||
align-self: stretch; | ||
background-color: ${({theme}) => theme.brand}; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
const Content = styled.View` | ||
flex: 1; | ||
align-self: stretch; | ||
`; | ||
|
||
const Buttons = styled.View` | ||
align-self: center; | ||
margin-top: 8px; | ||
padding: 20px; | ||
gap: 12px; | ||
position: absolute; | ||
bottom: 20px; | ||
`; | ||
|
||
//* This should be placed in page component or won't work | ||
WebBrowser.maybeCompleteAuthSession(); | ||
|
||
export default function Intro(): JSX.Element { | ||
useWarmUpBrowser(); | ||
|
||
const {theme} = useDooboo(); | ||
const {push} = useRouter(); | ||
const {top, bottom, left, right} = useSafeAreaInsets(); | ||
|
||
return ( | ||
<Container> | ||
<Stack.Screen options={{headerShown: false}} /> | ||
<Content style={css``}> | ||
<ScrollView | ||
contentContainerStyle={css` | ||
padding-top: ${top + 32 + 'px'}; | ||
padding-bottom: ${bottom + 'px'}; | ||
padding-left: ${left + 'px'}; | ||
padding-right: ${right + 'px'}; | ||
align-items: center; | ||
gap: 12px; | ||
`} | ||
> | ||
<Image | ||
source={IC_ICON} | ||
style={css` | ||
align-self: center; | ||
width: 80px; | ||
height: 80px; | ||
`} | ||
/> | ||
|
||
<Typography.Heading3 | ||
style={css` | ||
margin-top: 8px; | ||
padding: 0 16px; | ||
color: ${theme.text.basic}; | ||
text-align: center; | ||
`} | ||
> | ||
{t('common.appName')} | ||
</Typography.Heading3> | ||
<Typography.Body2 | ||
style={css` | ||
padding: 0 16px; | ||
margin-top: -4px; | ||
color: ${theme.text.label}; | ||
font-size: 16px; | ||
text-align: center; | ||
line-height: 22px; | ||
`} | ||
> | ||
{t('signIn.description')} | ||
</Typography.Body2> | ||
<Image | ||
source={IMG_CROSSPLATFORMS} | ||
style={css` | ||
margin-top: 24px; | ||
`} | ||
/> | ||
<View | ||
style={css` | ||
height: 220px; | ||
`} | ||
/> | ||
</ScrollView> | ||
<Buttons> | ||
<ButtonSocialSignIn strategy="oauth_github" /> | ||
<ButtonSocialSignIn strategy="oauth_google" /> | ||
<ButtonSocialSignIn strategy="oauth_apple" /> | ||
<Typography.Body4 | ||
style={css` | ||
margin-top: 4px; | ||
text-align: center; | ||
line-height: 20px; | ||
color: ${theme.text.label}; | ||
`} | ||
> | ||
{t('signIn.policyAgreement', { | ||
termsOfService: `**${t('signIn.termsOfService')}**`, | ||
privacyPolicy: `**${t('signIn.privacyPolicy')}**`, | ||
}) | ||
.split('**') | ||
.map((str, i) => | ||
i % 2 === 0 ? ( | ||
str | ||
) : ( | ||
<Typography.Body4 | ||
key={str} | ||
onPress={() => { | ||
if (str === t('signIn.privacyPolicy')) { | ||
return push('/privacyandpolicy'); | ||
} | ||
|
||
push('/termsofservice'); | ||
}} | ||
style={css` | ||
text-decoration-line: underline; | ||
color: ${theme.text.basic}; | ||
text-decoration-line: underline; | ||
`} | ||
> | ||
{str} | ||
</Typography.Body4> | ||
), | ||
)} | ||
</Typography.Body4> | ||
</Buttons> | ||
</Content> | ||
</Container> | ||
); | ||
} |
Oops, something went wrong.