Skip to content

Commit

Permalink
feat: Invalidate identity if not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jimhunty committed Jun 28, 2023
1 parent f5660ba commit 919a664
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from '../services/identity';
import type { MembersDataAPIResponse } from '../services/membership';
import { fetchMembershipData } from '../services/membership';
import { remoteConfigService } from 'src/services/remote-config';

Check failure on line 19 in projects/Mallard/src/authentication/authorizers/IdentityAuthorizer.ts

View workflow job for this annotation

GitHub Actions / build

`src/services/remote-config` import should occur before import of `../helpers`

type BasicCreds = {
email: string;
Expand Down Expand Up @@ -116,14 +117,20 @@ export default new Authorizer({
});
},
authWithCachedCredentials: async ([utc, mtc, lutc]) => {
const [nutoken, lutoken, mtoken] = await Promise.all([
utc.get(),
lutc.get(),
mtc.get(),
]);
const utoken = nutoken ?? lutoken;
if (!utoken || !mtoken) return InvalidResult();
return authWithTokens(utoken.password, mtoken.password);
const isIdentityEnabled =
remoteConfigService.getBoolean('identity_enabled');
if (isIdentityEnabled) {
const [nutoken, lutoken, mtoken] = await Promise.all([
utc.get(),
lutc.get(),
mtc.get(),
]);
const utoken = nutoken ?? lutoken;
if (!utoken || !mtoken) return InvalidResult();
return authWithTokens(utoken.password, mtoken.password);
} else {
return InvalidResult();
}
},
checkUserHasAccess: canViewEdition,
});

0 comments on commit 919a664

Please sign in to comment.