forked from timothymiller/t4-app
-
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.
Route for native oauth to open with WebBrowser.openAuthSessionAsync
- Loading branch information
Showing
10 changed files
with
100 additions
and
70 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { OAuthSignInScreen } from 'app/features/oauth/screen' | ||
import Head from 'next/head' | ||
|
||
export default function Page() { | ||
return ( | ||
<> | ||
<Head> | ||
<title>OAuth Sign In</title> | ||
</Head> | ||
<OAuthSignInScreen /> | ||
</> | ||
) | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { AuthProviderName } from '@t4/api/src/auth/shared' | ||
import { Paragraph } from '@t4/ui' | ||
import { useSignIn } from 'app/utils/auth' | ||
import { useEffect } from 'react' | ||
import { createParam } from 'solito' | ||
|
||
const { useParam } = createParam<{ provider: AuthProviderName, redirectTo: string }>() | ||
|
||
export const OAuthSignInScreen = (): React.ReactNode => { | ||
const { signIn } = useSignIn() | ||
const [provider] = useParam('provider') | ||
const [redirectTo] = useParam('redirectTo') | ||
|
||
useEffect(() => { | ||
if (!provider) return | ||
if (!window) return | ||
const exec = async () => { | ||
const res = await signIn({ provider, redirectTo }) | ||
console.log('signIn result', res) | ||
if (!res?.oauthRedirect) { | ||
if (redirectTo) { | ||
window.location.href = redirectTo | ||
} | ||
} else { | ||
window.location.href = res.oauthRedirect | ||
} | ||
} | ||
exec() | ||
}, [provider]) | ||
|
||
return ( | ||
<Paragraph p="$8">Redirecting to sign in...</Paragraph> | ||
) | ||
} |
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