mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-17 21:00:45 +00:00
Add QControllerV1 usage and setGotAuthenticationInAllControllers method to replace calling it on each controller instance
This commit is contained in:
@ -48,7 +48,7 @@ export default function useAnonymousAuthenticationModule({setIsFullyAuthenticate
|
|||||||
{
|
{
|
||||||
console.log("Generating random token...");
|
console.log("Generating random token...");
|
||||||
setIsFullyAuthenticated(true);
|
setIsFullyAuthenticated(true);
|
||||||
qController.setGotAuthentication();
|
Client.setGotAuthenticationInAllControllers();
|
||||||
setCookie(SESSION_UUID_COOKIE_NAME, Md5.hashStr(`${new Date()}`), {path: "/"});
|
setCookie(SESSION_UUID_COOKIE_NAME, Md5.hashStr(`${new Date()}`), {path: "/"});
|
||||||
console.log("Token generation complete.");
|
console.log("Token generation complete.");
|
||||||
};
|
};
|
||||||
|
@ -30,6 +30,7 @@ import {useCookies} from "react-cookie";
|
|||||||
import {useNavigate, useSearchParams} from "react-router-dom";
|
import {useNavigate, useSearchParams} from "react-router-dom";
|
||||||
|
|
||||||
const qController = Client.getInstance();
|
const qController = Client.getInstance();
|
||||||
|
const qControllerV1 = Client.getInstanceV1();
|
||||||
|
|
||||||
interface Props
|
interface Props
|
||||||
{
|
{
|
||||||
@ -131,7 +132,7 @@ export default function useAuth0AuthenticationModule({setIsFullyAuthenticated, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
setIsFullyAuthenticated(true);
|
setIsFullyAuthenticated(true);
|
||||||
qController.setGotAuthentication();
|
Client.setGotAuthenticationInAllControllers();
|
||||||
|
|
||||||
setLoggedInUser(auth0User);
|
setLoggedInUser(auth0User);
|
||||||
console.log("Token load complete.");
|
console.log("Token load complete.");
|
||||||
|
@ -80,7 +80,7 @@ export default function useOAuth2AuthenticationModule({setIsFullyAuthenticated,
|
|||||||
console.log(`we have new session UUID: ${newSessionUuid}`);
|
console.log(`we have new session UUID: ${newSessionUuid}`);
|
||||||
|
|
||||||
setIsFullyAuthenticated(true);
|
setIsFullyAuthenticated(true);
|
||||||
qController.setGotAuthentication();
|
Client.setGotAuthenticationInAllControllers();
|
||||||
|
|
||||||
setLoggedInUser(values?.user);
|
setLoggedInUser(values?.user);
|
||||||
console.log("Token load complete.");
|
console.log("Token load complete.");
|
||||||
@ -109,7 +109,7 @@ export default function useOAuth2AuthenticationModule({setIsFullyAuthenticated,
|
|||||||
const {values} = await qController.manageSession(null, sessionUuid, null);
|
const {values} = await qController.manageSession(null, sessionUuid, null);
|
||||||
|
|
||||||
setIsFullyAuthenticated(true);
|
setIsFullyAuthenticated(true);
|
||||||
qController.setGotAuthentication();
|
Client.setGotAuthenticationInAllControllers();
|
||||||
|
|
||||||
setLoggedInUser(values?.user);
|
setLoggedInUser(values?.user);
|
||||||
console.log("Token load complete.");
|
console.log("Token load complete.");
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {QController} from "@kingsrook/qqq-frontend-core/lib/controllers/QController";
|
import {QController} from "@kingsrook/qqq-frontend-core/lib/controllers/QController";
|
||||||
|
import {QControllerV1} from "@kingsrook/qqq-frontend-core/lib/controllers/QControllerV1";
|
||||||
import {QException} from "@kingsrook/qqq-frontend-core/lib/exceptions/QException";
|
import {QException} from "@kingsrook/qqq-frontend-core/lib/exceptions/QException";
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -29,6 +30,7 @@ import {QException} from "@kingsrook/qqq-frontend-core/lib/exceptions/QException
|
|||||||
class Client
|
class Client
|
||||||
{
|
{
|
||||||
private static qController: QController;
|
private static qController: QController;
|
||||||
|
private static qControllerV1: QControllerV1;
|
||||||
private static unauthorizedCallback: () => void;
|
private static unauthorizedCallback: () => void;
|
||||||
|
|
||||||
private static handleException(exception: QException)
|
private static handleException(exception: QException)
|
||||||
@ -54,6 +56,22 @@ class Client
|
|||||||
return this.qController;
|
return this.qController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static getInstanceV1(path: string = "/qqq/v1")
|
||||||
|
{
|
||||||
|
if (this.qControllerV1 == null)
|
||||||
|
{
|
||||||
|
this.qControllerV1 = new QControllerV1(path, this.handleException);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.qControllerV1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static setGotAuthenticationInAllControllers()
|
||||||
|
{
|
||||||
|
Client.getInstance().setGotAuthentication();
|
||||||
|
Client.getInstanceV1().setGotAuthentication();
|
||||||
|
}
|
||||||
|
|
||||||
static setUnauthorizedCallback(unauthorizedCallback: () => void)
|
static setUnauthorizedCallback(unauthorizedCallback: () => void)
|
||||||
{
|
{
|
||||||
Client.unauthorizedCallback = unauthorizedCallback;
|
Client.unauthorizedCallback = unauthorizedCallback;
|
||||||
|
Reference in New Issue
Block a user