From 46f7f51d3aebd7a2fe15932172dbf9568ededaf9 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Fri, 10 Jan 2025 00:38:13 -0500 Subject: [PATCH] Fix the URl for google auth --- src/views/Authorization/LoginView.jsx | 148 +++++++++++++------------- 1 file changed, 76 insertions(+), 72 deletions(-) diff --git a/src/views/Authorization/LoginView.jsx b/src/views/Authorization/LoginView.jsx index b75581f..6a3eb2d 100644 --- a/src/views/Authorization/LoginView.jsx +++ b/src/views/Authorization/LoginView.jsx @@ -1,3 +1,6 @@ +import { Capacitor } from '@capacitor/core' +import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth' +import { Settings } from '@mui/icons-material' import GoogleIcon from '@mui/icons-material/Google' import { Avatar, @@ -15,15 +18,11 @@ import Cookies from 'js-cookie' import React from 'react' import { useNavigate } from 'react-router-dom' import { LoginSocialGoogle } from 'reactjs-social-login' -import { API_URL, GOOGLE_CLIENT_ID, REDIRECT_URL } from '../../Config' +import { GOOGLE_CLIENT_ID, REDIRECT_URL } from '../../Config' import { UserContext } from '../../contexts/UserContext' import Logo from '../../Logo' import { GetUserProfile, login } from '../../utils/Fetcher' -import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth'; -import { Capacitor } from '@capacitor/core' -import { Settings } from '@mui/icons-material' - - +import { apiManager } from '../../utils/TokenManager' const LoginView = () => { const { userProfile, setUserProfile } = React.useContext(UserContext) @@ -34,7 +33,6 @@ const LoginView = () => { const handleSubmit = async e => { e.preventDefault() login(username, password) - .then(response => { if (response.status === 200) { return response.json().then(data => { @@ -63,7 +61,8 @@ const LoginView = () => { } const loggedWithProvider = function (provider, data) { - return fetch(API_URL + `/auth/${provider}/callback`, { + const baseURL = apiManager.getApiURL() + return fetch(`${baseURL}/auth/${provider}/callback`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -141,20 +140,21 @@ const LoginView = () => { boxShadow: 'md', }} > - { - Navigate('/login/settings') - - } - } - > + { + Navigate('/login/settings') + }} + > + {' '} + + {/* logo { )} or {!Capacitor.isNativePlatform() && ( - - { - loggedWithProvider(provider, data) - }} - onReject={err => { - setError("Couldn't log in with Google, please try again") - }} - > + + { + loggedWithProvider(provider, data) + }} + onReject={err => { + setError("Couldn't log in with Google, please try again") + }} + > + + + + )} + + {Capacitor.isNativePlatform() && ( + - - )} - - {Capacitor.isNativePlatform() && ( - - - + )} -