diff --git a/client/package-lock.json b/client/package-lock.json index 5f58f8b..5adeb6f 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -10,6 +10,7 @@ "@aspida/axios": "^1.14.0", "@aws-amplify/ui-react": "^6.3.0", "@aws-sdk/client-cognito-identity-provider": "^3.645.0", + "@fakerjs/word": "^1.0.1", "aspida": "^1.14.0", "aws-amplify": "^6.6.0", "axios": "^1.7.7", @@ -2176,6 +2177,14 @@ "node": ">=6.9.0" } }, + "node_modules/@fakerjs/word": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@fakerjs/word/-/word-1.0.1.tgz", + "integrity": "sha512-ilyTmSakl4K/osCEE5kUdyAFXxZnmh3WLXlQHKU4ytbkHLHh67f+h25JVrrD+N3Dv7D/7gQlfj/YBH+QuERJlw==", + "engines": { + "node": ">=12" + } + }, "node_modules/@file-cache/core": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@file-cache/core/-/core-2.0.0.tgz", diff --git a/client/package.json b/client/package.json index 5194885..2bba197 100644 --- a/client/package.json +++ b/client/package.json @@ -20,6 +20,7 @@ "@aspida/axios": "^1.14.0", "@aws-amplify/ui-react": "^6.3.0", "@aws-sdk/client-cognito-identity-provider": "^3.645.0", + "@fakerjs/word": "^1.0.1", "aspida": "^1.14.0", "aws-amplify": "^6.6.0", "axios": "^1.7.7", diff --git a/client/pages/oauth2/authorize.module.css b/client/pages/oauth2/authorize.module.css new file mode 100644 index 0000000..b3fc7df --- /dev/null +++ b/client/pages/oauth2/authorize.module.css @@ -0,0 +1,46 @@ +.container { + max-width: 500px; + padding: 32px 24px; + margin: 0 auto; +} + +.btn { + padding: 6px 16px; + font-weight: bold; + color: blue; + cursor: pointer; + background: #fff; + border: 1px solid #ccc; + border-radius: 6px; +} + +.inputLabel { + font-size: 14px; + color: #777; +} + +.textInput { + width: 100%; + padding: 4px 8px; + border: 1px solid #aaa; + border-radius: 4px; +} + +.textInput:focus { + outline-color: blue; +} + +.submitBtn { + padding: 6px 16px; + font-weight: bold; + color: #fff; + cursor: pointer; + background: blue; + border: none; + border-radius: 6px; +} + +.submitBtn:disabled { + cursor: not-allowed; + background: #aaa; +} diff --git a/client/pages/oauth2/authorize.page.tsx b/client/pages/oauth2/authorize.page.tsx index 48eccee..fda576b 100644 --- a/client/pages/oauth2/authorize.page.tsx +++ b/client/pages/oauth2/authorize.page.tsx @@ -1,16 +1,106 @@ import type { OAuthConfig } from '@aws-amplify/core'; +import word from '@fakerjs/word'; +import type { MaybeId } from 'common/types/brandedId'; +import { Spacer } from 'components/Spacer'; +import { useRouter } from 'next/router'; +import { useState } from 'react'; +import { z } from 'zod'; +import styles from './authorize.module.css'; export type Query = { redirect_uri: string; response_type: OAuthConfig['responseType']; - client_id: string; + client_id: MaybeId['userPoolClient']; identity_provider: OAuthConfig['providers']; scope: OAuthConfig['scopes']; state: string; }; +const AddAccount = (props: { onBack: () => void }) => { + const [email, setEmail] = useState(''); + const [displayName, setDisplayName] = useState(''); + const [photoUrl, setPhotoUrl] = useState(''); + const data = z + .object({ + email: z.string().email(), + displayName: z.string(), + photoUrl: z.literal('').or(z.string().url().optional()), + }) + .safeParse({ email, displayName, photoUrl }); + const setFakeVals = () => { + const fakeWord = word({ length: 8 }); + + setEmail(`${fakeWord}@magnito.com`); + setDisplayName(fakeWord); + }; + + return ( +
+ + +
+
Email
+ + setEmail(e.currentTarget.value)} + /> + +
Display name (optional)
+ + setDisplayName(e.currentTarget.value)} + /> + +
Profile photo URL (optional)
+ + setPhotoUrl(e.currentTarget.value)} + /> + +
+ + +
+ +
+ ); +}; + const Authorize = () => { - return
aaa
; + const router = useRouter(); + const provider = router.query.identity_provider; + const [mode, setMode] = useState<'default' | 'add'>('default'); + + return ( +
+

Sign-in with {provider}

+ +
No {provider} accounts exist in Magnito.
+ + {mode === 'default' ? ( + + ) : ( + setMode('default')} /> + )} +
+ ); }; export default Authorize;