How to use the framework/appContext/AppContextAccessor.AppContextAccessor.getAppContext function in framework

To help you get started, we’ve selected a few framework examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github navtrack / navtrack / Navtrack.Core / ClientApp / src / services / AccountService.ts View on Github external
getUserInfo: async () => {
    const appContext = AppContextAccessor.getAppContext();

    if (appContext.authenticationInfo.authenticated && !appContext.user) {
      const user = await AccountApi.get();

      AppContextAccessor.setAppContext({ ...AppContextAccessor.getAppContext(), user: user });
    }
  }
};
github navtrack / navtrack / Navtrack.Core / ClientApp / src / services / AccountService.ts View on Github external
getUserInfo: async () => {
    const appContext = AppContextAccessor.getAppContext();

    if (appContext.authenticationInfo.authenticated && !appContext.user) {
      const user = await AccountApi.get();

      AppContextAccessor.setAppContext({ ...AppContextAccessor.getAppContext(), user: user });
    }
  }
};
github navtrack / navtrack / Navtrack.Core / ClientApp / src / framework / authentication / AuthorizationService.ts View on Github external
isAuthorized: (userRole?: UserRole) => {
    var appContext = AppContextAccessor.getAppContext();

    return (
      appContext.authenticationInfo.authenticated &&
      (userRole === undefined ||
        (appContext.user !== undefined && appContext.user.role === userRole))
    );
  }
};
github navtrack / navtrack / Navtrack.Core / ClientApp / src / framework / httpClient / HttpClient.ts View on Github external
function getHeaders(contentType?: string | undefined): Record {
  let headers: Record = {};
  let appContext = AppContextAccessor.getAppContext();

  if (appContext.authenticationInfo.authenticated && appContext.authenticationInfo.access_token) {
    headers["Authorization"] = `Bearer ${appContext.authenticationInfo.access_token}`;
  }
  headers["Content-Type"] = contentType ? contentType : "application/json";

  return headers;
}
github navtrack / navtrack / Navtrack.Core / ClientApp / src / framework / authentication / AuthenticationService.ts View on Github external
checkAndRenewAccessToken: async (): Promise => {
    let appContext = AppContextAccessor.getAppContext();

    if (appContext.authenticationInfo.authenticated) {
      if (accessTokenIsExpired(appContext.authenticationInfo.expiry_date)) {
        const tokenResponse = await IdentityApi.refreshToken(
          appContext.authenticationInfo.refresh_token
        );

        if (renewFailed(tokenResponse)) {
          AuthenticationService.clearAuthenticationInfo(true);

          return false;
        }

        AppContextAccessor.setAppContext(appContext => {
          return {
            ...appContext,