This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
route.jsx
47 lines (37 loc) · 1.2 KB
/
route.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {ErrorPageTypes} from 'utils/constants';
import {isGuest} from 'utils/utils.jsx';
export function importComponentSuccess(callback) {
return (comp) => callback(null, comp.default);
}
export function createGetChildComponentsFunction(arrayOfComponents) {
return (locaiton, callback) => callback(null, arrayOfComponents);
}
export const notFoundParams = {
type: ErrorPageTypes.PAGE_NOT_FOUND,
};
const mfaPaths = [
'/mfa/setup',
'/mfa/confirm',
];
const mfaAuthServices = [
'',
'email',
'ldap',
];
export function checkIfMFARequired(user, license, config, path) {
if (license.MFA === 'true' &&
config.EnableMultifactorAuthentication === 'true' &&
config.EnforceMultifactorAuthentication === 'true' &&
mfaPaths.indexOf(path) === -1) {
if (isGuest(user) && config.GuestAccountsEnforceMultifactorAuthentication !== 'true') {
return false;
}
if (user && !user.mfa_active &&
mfaAuthServices.indexOf(user.auth_service) !== -1) {
return true;
}
}
return false;
}