@@ -4,7 +4,7 @@ import {Card} from "../card/Card";
44import { Button } from "../button/Button" ;
55import { IconKey , IconLogin , IconMail } from "@tabler/icons-react" ;
66import { Text } from "../text/Text" ;
7- import { PasswordInput } from "./PasswordInput" ;
7+ import { PasswordInput , passwordValidation } from "./PasswordInput" ;
88import { TextInput } from "./TextInput" ;
99import { EmailInput , emailValidation } from "./EmailInput" ;
1010import { NumberInput } from "./NumberInput" ;
@@ -33,17 +33,14 @@ export const Login = () => {
3333 if ( ! emailValidation ( value ) ) return "Please provide a valid email"
3434 return null
3535 } ,
36- password : ( value ) => {
37- if ( ! value ) return "Password is required"
38- return null
39- }
36+ password : passwordValidation
4037 } ,
4138 onSubmit : ( values ) => {
4239 console . log ( values )
4340 }
4441 } )
4542
46- return < Card color = { "primary " } maw = { 300 } >
43+ return < Card color = { "secondary " } maw = { "15vw" } >
4744 < Text size = { "xl" } display = { "block" } hierarchy = { "primary" } > Login</ Text >
4845 < br />
4946 < Text size = { "sm" } display = { "block" } >
@@ -73,71 +70,10 @@ export const Login = () => {
7370 justifyContent : "space-between" ,
7471 gap : ".75rem" ,
7572 } } >
76- < Button w = { "100%" } color = { "secondary" } variant = { "outlined "} onClick = { validate } >
73+ < Button w = { "100%" } color = { "tertiary " } onClick = { validate } >
7774 Login
7875 </ Button >
7976
80- < Button w = { "100%" } color = { "secondary" } variant = { "outlined" } onClick = { ( ) => {
81- const publicKeyCredentialCreationOptions : PublicKeyCredentialCreationOptions = {
82- challenge : crypto . getRandomValues ( new Uint8Array ( 32 ) ) ,
83- rp : { name : "Code0 Dev" , id : "localhost" } ,
84- user : {
85- id : Uint8Array . from ( "nico" , c => c . charCodeAt ( 0 ) ) ,
86- name : "nico@localhost" ,
87- displayName : "Nico Sammito" ,
88- } ,
89- pubKeyCredParams : [
90- { type : "public-key" , alg : - 7 } ,
91- { type : "public-key" , alg : - 257 }
92- ] as const ,
93- authenticatorSelection : {
94- userVerification : "preferred" as UserVerificationRequirement ,
95- // authenticatorAttachment: "platform" as AuthenticatorAttachment,
96- } ,
97- timeout : 60000 ,
98- }
99-
100- navigator . credentials . create ( {
101- publicKey : publicKeyCredentialCreationOptions ,
102- } ) . then ( cred => {
103- console . log ( "Passkey registriert:" , cred ) ;
104- } ) ;
105- } } >
106- Login with Passkeys
107- </ Button >
108-
109- < Button
110- w = { "100%" }
111- color = { "primary" }
112- variant = { "normal" }
113- onClick = { async ( ) => {
114- const publicKeyCredentialRequestOptions : PublicKeyCredentialRequestOptions = {
115- challenge : crypto . getRandomValues ( new Uint8Array ( 32 ) ) , // Demo: sollte vom Server kommen!
116- rpId : "localhost" ,
117- userVerification : "preferred" as UserVerificationRequirement ,
118- timeout : 60000 ,
119- // allowCredentials: [
120- // {
121- // id: new Uint8Array([/* credentialId als Uint8Array vom Server */]).buffer,
122- // type: "public-key" as PublicKeyCredentialType,
123- // }
124- // ],
125- } ;
126-
127- try {
128- await navigator . credentials . get ( {
129- publicKey : publicKeyCredentialRequestOptions ,
130- } ) . then ( value => {
131- console . log ( "Passkey Login erfolgreich:" , value ) ;
132- } ) ;
133- } catch ( err ) {
134- console . error ( "Login fehlgeschlagen:" , err ) ;
135- }
136- } }
137- >
138- Login with Passkeys
139- </ Button >
140-
14177 </ div >
14278 </ Card >
14379
0 commit comments