mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-26 06:09:41 +00:00
feat: client testing api , add ouath2
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
import { Alert, Box, Button, Container, Paper, TextField, Typography } from '@mui/material';
|
||||
import React, { useState } from 'react';
|
||||
import AppleSignin from 'react-apple-signin-auth';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useAuth } from '../../contexts/AuthContext';
|
||||
import { GrantType } from '../../enums';
|
||||
import { AppleLogin } from './AppleLogin';
|
||||
import { GoogleLogin } from './GoogleLogin';
|
||||
export const LoginForm = () => {
|
||||
const { login } = useAuth();
|
||||
const navigate = useNavigate();
|
||||
@ -19,7 +21,7 @@ export const LoginForm = () => {
|
||||
setLoading(true);
|
||||
|
||||
try {
|
||||
await login(formData.email, formData.password);
|
||||
await login({ email: formData.email, password: formData.password, grantType: GrantType.PASSWORD });
|
||||
navigate('/dashboard');
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Login failed. Please check your credentials.');
|
||||
@ -35,7 +37,6 @@ export const LoginForm = () => {
|
||||
[name]: value,
|
||||
}));
|
||||
};
|
||||
console.log(process.env);
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
@ -138,44 +139,8 @@ export const LoginForm = () => {
|
||||
>
|
||||
signup
|
||||
</Button>
|
||||
|
||||
<AppleSignin
|
||||
/** Auth options passed to AppleID.auth.init() */
|
||||
authOptions={{
|
||||
/** Client ID - eg: 'com.example.com' */
|
||||
clientId: process?.env.REACT_APP_APPLE_CLIENT_ID!,
|
||||
|
||||
scope: 'email name',
|
||||
/** Requested scopes, seperated by spaces - eg: 'email name' */
|
||||
/** Apple's redirectURI - must be one of the URIs you added to the serviceID - the undocumented trick in apple docs is that you should call auth from a page that is listed as a redirectURI, localhost fails */
|
||||
redirectURI: process?.env.REACT_APP_APPLE_REDIRECT_URI!,
|
||||
|
||||
state: 'default',
|
||||
|
||||
/** Uses popup auth instead of redirection */
|
||||
usePopup: true,
|
||||
}} // REQUIRED
|
||||
/** General props */
|
||||
uiType="dark"
|
||||
/** className */
|
||||
className="apple-auth-btn"
|
||||
/** Removes default style tag */
|
||||
noDefaultStyle={false}
|
||||
/** Allows to change the button's children, eg: for changing the button text */
|
||||
buttonExtraChildren="Continue with Apple"
|
||||
/** Extra controlling props */
|
||||
/** Called upon signin success in case authOptions.usePopup = true -- which means auth is handled client side */
|
||||
onSuccess={(response: any) => {
|
||||
console.log(response);
|
||||
}} // default = undefined
|
||||
/** Called upon signin error */
|
||||
onError={(error: any) => console.error(error)} // default = undefined
|
||||
/** Skips loading the apple script if true */
|
||||
skipScript={false} // default = undefined
|
||||
/** Apple image props */
|
||||
|
||||
/** render function - called with all props - can be used to fully customize the UI by rendering your own component */
|
||||
/>
|
||||
<AppleLogin setError={setError} setLoading={setLoading} />
|
||||
<GoogleLogin setError={setError} setLoading={setLoading} />
|
||||
</Box>
|
||||
</Paper>
|
||||
</Container>
|
||||
|
Reference in New Issue
Block a user