-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add client authn verification page (#929)
* Add client authn verification page * Update for renamed device auth endpoints * Bump OMICRON_VERSION * prove oxidecomputer/omicron#1303 fixes it * make typescript happy * use omicron version that's on main now that it's merged * quick polish on auth and success state Co-authored-by: David Crespo <[email protected]>
- Loading branch information
1 parent
37c7c40
commit a779fe5
Showing
4 changed files
with
82 additions
and
0 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,17 @@ | ||
import { Success16Icon } from '@oxide/ui' | ||
|
||
/** | ||
* Device authorization success page | ||
*/ | ||
export default function DeviceAuthSuccessPage() { | ||
return ( | ||
<div className="space-y-4 max-w-sm text-center"> | ||
<h1 className="text-sans-2xl">Device authentication</h1> | ||
<h2 className="text-sans-3xl flex items-center text-accent justify-center"> | ||
<Success16Icon width={40} height={40} className="mr-3 text-accent" /> | ||
Success! | ||
</h2> | ||
<p>Your device is now logged in.</p> | ||
</div> | ||
) | ||
} |
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,48 @@ | ||
import { useNavigate, useSearchParams } from 'react-router-dom' | ||
|
||
import { useApiMutation } from '@oxide/api' | ||
import { Button, Warning12Icon } from '@oxide/ui' | ||
|
||
import { useToast } from '../hooks' | ||
|
||
/** | ||
* Device authorization verification page | ||
*/ | ||
export default function DeviceAuthVerifyPage() { | ||
const [searchParams] = useSearchParams() | ||
const navigate = useNavigate() | ||
const addToast = useToast() | ||
const confirmPost = useApiMutation('deviceAuthConfirm', { | ||
onSuccess: () => { | ||
navigate('/device/success') | ||
}, | ||
onError: () => { | ||
addToast({ | ||
title: 'Token denied', | ||
icon: <Warning12Icon />, | ||
variant: 'error', | ||
timeout: 4000, | ||
}) | ||
}, | ||
}) | ||
const userCode = searchParams.get('user_code') | ||
|
||
return ( | ||
<div className="space-y-4 max-w-sm text-center"> | ||
<h1 className="text-sans-2xl">Device authentication</h1> | ||
<p>Make sure this code matches the one shown on the device you are authenticating.</p> | ||
<h2 className="text-sans-3xl border p-4">{userCode}</h2> | ||
<Button | ||
className="w-full" | ||
disabled={confirmPost.isLoading || confirmPost.isSuccess || !userCode} | ||
onClick={() => { | ||
// we know `userCode` is non-null because the button is disabled | ||
// otherwise, but let's make TS happy | ||
if (userCode) confirmPost.mutate({ body: { userCode } }) | ||
}} | ||
> | ||
Log in on device | ||
</Button> | ||
</div> | ||
) | ||
} |
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
a779fe5
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.
@plotnick is attempting to deploy a commit to the Oxide Computer Company Team on Vercel.
To accomplish this, @plotnick needs to request access to the Team.
Afterwards, an owner of the Team is required to accept their membership request.
If you're already a member of the respective Vercel Team, make sure that your Personal Vercel Account is connected to your GitHub account.