feat(auth): Add Authorization Code Flow and new Keycloak recipes with new video tutorials (#4234)
Co-authored-by: Alireza <ar.sedghi@gmail.com>
This commit is contained in:
1 parent
998302eb85
commit
aefa6d94df
81 files changed
+6525
-471
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
function CallbackPage({ userManager, onRedirectSuccess }) {
|
||||
@@ -6,10 +6,12 @@ function CallbackPage({ userManager, onRedirectSuccess }) {
|
||||
throw new Error(error);
|
||||
};
|
||||
|
||||
userManager
|
||||
.signinRedirectCallback()
|
||||
.then(user => onRedirectSuccess(user))
|
||||
.catch(error => onRedirectError(error));
|
||||
useEffect(() => {
|
||||
userManager
|
||||
.signinRedirectCallback()
|
||||
.then(user => onRedirectSuccess(user))
|
||||
.catch(error => onRedirectError(error));
|
||||
}, [userManager, onRedirectSuccess]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import { useUserAuthentication } from '@ohif/ui';
|
||||
|
||||
export const PrivateRoute = ({ children, handleUnauthenticated }) => {
|
||||
|
||||
@@ -81,7 +81,7 @@ export default function buildModeRoutes({
|
||||
routes.push({
|
||||
path,
|
||||
children,
|
||||
private: true, // todo: all mode routes are private for now
|
||||
private: true,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -138,18 +138,20 @@ const createRoutes = ({
|
||||
|
||||
const { userAuthenticationService } = servicesManager.services;
|
||||
|
||||
// Note: PrivateRoutes in react-router-dom 6.x should be defined within
|
||||
// a Route element
|
||||
// All routes are private by default and then we let the user auth service
|
||||
// to check if it is enabled or not
|
||||
// Todo: I think we can remove the second public return below
|
||||
return (
|
||||
<Routes>
|
||||
{allRoutes.map((route, i) => {
|
||||
return route.private === true ? (
|
||||
<Route
|
||||
key={i}
|
||||
exact
|
||||
path={route.path}
|
||||
element={
|
||||
<PrivateRoute handleUnauthenticated={() => userAuthenticationService.handleUnauthenticated()}>
|
||||
<PrivateRoute
|
||||
handleUnauthenticated={() => userAuthenticationService.handleUnauthenticated()}
|
||||
>
|
||||
<RouteWithErrorBoundary route={route} />
|
||||
</PrivateRoute>
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user