-
Notifications
You must be signed in to change notification settings - Fork 529
/
Copy pathAuthorize.jsx
77 lines (63 loc) · 2.61 KB
/
Authorize.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import GuestLayout from '@/Layouts/GuestLayout';
import PrimaryButton from '@/Components/PrimaryButton';
import SecondaryButton from '@/Components/SecondaryButton';
import { Head, Link, useForm } from '@inertiajs/react';
export default function Authorize({ user, client, scopes, authToken }) {
const { post, processing, transform } = useForm({
state: route().params.state,
client_id: client.id,
auth_token: authToken,
});
const approve = (e) => {
e.preventDefault();
post(route('passport.authorizations.approve'));
};
const deny = (e) => {
e.preventDefault();
transform((data) => ({
...data,
_method: 'delete',
}));
post(route('passport.authorizations.deny'));
};
return (
<GuestLayout>
<Head title="Authorization Request" />
<div className="mb-4 text-gray-600 text-center">
<p>
<strong>{user.name}</strong>
</p>
<p className="text-sm">{user.email}</p>
</div>
<div className="mb-4 text-sm text-gray-600">
<strong>{client.name}</strong> is requesting permission to access your account.
</div>
{scopes.length > 0 && (
<div className="mb-4 text-sm text-gray-600">
<p className="pb-1">This application will be able to:</p>
<ul className="list-inside list-disc">
{scopes.map((scope) => (
<li>{scope.description}</li>
))}
</ul>
</div>
)}
<div className="flex flex-row-reverse gap-3 mt-4 flex-wrap items-center">
<form onSubmit={approve}>
<PrimaryButton disabled={processing}>Authorize</PrimaryButton>
</form>
<form onSubmit={deny}>
<SecondaryButton type="submit" disabled={processing}>
Decline
</SecondaryButton>
</form>
<Link
href={route('passport.authorizations.authorize', { ...route().params, prompt: 'login' })}
className="underline text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:focus:ring-offset-gray-800"
>
Log into another account
</Link>
</div>
</GuestLayout>
);
}