react-adal icon indicating copy to clipboard operation
react-adal copied to clipboard

App is not rendered when user doesn't have First name and Last name (not required in AD)

Open J-theGit opened this issue 6 years ago • 0 comments

Hi, I stumbled upon a bug where the app will not be rendered (blank white screen) when the user doesn't have First name and/or Last name setup in Azure AD. In this scenario the Azure AD authentication succeeds, but react-adal will not render the app (the require below will not run)

import { runWithAdal } from 'react-adal';
import { authContext } from './config/adalConfig';

const DO_NOT_LOGIN = false;


// auth with Azure AD. ADAL will handle entire auth
runWithAdal(authContext, () => {

    // eslint-disable-next-line
    require('./indexApp.js');

}, DO_NOT_LOGIN);

This is my adal config:

import { AuthenticationContext } from 'react-adal';

export const adalConfig = {
    tenant: process.env.REACT_APP_AD_TENANT,
    clientId: process.env.REACT_APP_AD_CLIENTID,
    redirectUri: process.env.REACT_APP_SELF_DOMAIN,
    endpoints: {
        api: process.env.REACT_APP_AD_ENDPOINT,
    },
    cacheLocation: 'sessionStorage',
};

export const authContext = new AuthenticationContext(adalConfig);

export const getToken = () => authContext.getCachedToken(adalConfig.clientId);
export const getUser = () => authContext.getCachedUser(adalConfig.clientId);

J-theGit avatar Nov 29 '19 14:11 J-theGit