-
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.
Add initial implementation of app login with qr code
- Loading branch information
Showing
4 changed files
with
127 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,78 @@ | ||
import { | ||
SettingsFlow, | ||
UiNode, | ||
UiNodeInputAttributes, | ||
UpdateSettingsFlowBody, | ||
} from "@ory/client" | ||
import { AxiosError } from "axios" | ||
import type { NextPage } from "next" | ||
import Head from "next/head" | ||
import Link from "next/link" | ||
import { useRouter } from "next/router" | ||
import { ReactNode, useEffect, useState } from "react" | ||
import QRCode from "react-qr-code" | ||
|
||
import { profileQuestions } from "../data/profile-questionnaire" | ||
import { | ||
ActionCard, | ||
CenterLink, | ||
Flow, | ||
Messages, | ||
Methods, | ||
CardTitle, | ||
InnerCard, | ||
} from "../pkg" | ||
import { handleFlowError } from "../pkg/errors" | ||
import ory from "../pkg/sdk" | ||
import { H3 } from "@ory/themes" | ||
|
||
interface Props { | ||
flow?: SettingsFlow | ||
only?: Methods | ||
} | ||
|
||
function ProfileCard({ children }: Props & { children: ReactNode }) { | ||
return ( | ||
<ActionCard wide className="cardMargin"> | ||
{children} | ||
</ActionCard> | ||
) | ||
} | ||
|
||
const Apps: NextPage = () => { | ||
const [flow, setFlow] = useState<SettingsFlow>() | ||
|
||
// Get ?flow=... from the URL | ||
const router = useRouter() | ||
const DefaultHydraUrl = "http://localhost:4444" | ||
|
||
useEffect(() => { | ||
// If the router is not ready yet, or we already have a flow, do nothing. | ||
if (!router.isReady) { | ||
return | ||
} | ||
}, []) | ||
|
||
return ( | ||
<> | ||
<Head> | ||
<title>App Login</title> | ||
<meta name="description" content="NextJS + React + Vercel + Ory" /> | ||
</Head> | ||
<ProfileCard> | ||
<CardTitle>App Login</CardTitle> | ||
<div className="center"> | ||
<p>Scan the QR code below with your app.</p> | ||
<QRCode value={DefaultHydraUrl} size={140} /> | ||
</div> | ||
</ProfileCard> | ||
<ActionCard wide> | ||
<Link href="/" passHref> | ||
<CenterLink>Go back</CenterLink> | ||
</Link> | ||
</ActionCard> | ||
</> | ||
) | ||
} | ||
|
||
export default Apps |
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