summaryrefslogtreecommitdiffstats
path: root/webapp/routes/route_utils.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/routes/route_utils.jsx')
-rw-r--r--webapp/routes/route_utils.jsx26
1 files changed, 26 insertions, 0 deletions
diff --git a/webapp/routes/route_utils.jsx b/webapp/routes/route_utils.jsx
index f3a159cbc..f36d7bcd8 100644
--- a/webapp/routes/route_utils.jsx
+++ b/webapp/routes/route_utils.jsx
@@ -2,6 +2,7 @@
// See License.txt for license information.
import * as Utils from 'utils/utils.jsx';
+import UserStore from 'stores/user_store.jsx';
export function importComponentSuccess(callback) {
return (comp) => callback(null, comp.default);
@@ -18,3 +19,28 @@ export const notFoundParams = {
linkmessage: Utils.localizeMessage('error.not_found.link_message', 'Back to Mattermost')
};
+const mfaPaths = [
+ '/mfa/setup',
+ '/mfa/confirm'
+];
+
+const mfaAuthServices = [
+ '',
+ 'email',
+ 'ldap'
+];
+
+export function checkIfMFARequired(state) {
+ if (window.mm_license.MFA === 'true' &&
+ window.mm_config.EnableMultifactorAuthentication === 'true' &&
+ window.mm_config.EnforceMultifactorAuthentication === 'true' &&
+ mfaPaths.indexOf(state.location.pathname) === -1) {
+ const user = UserStore.getCurrentUser();
+ if (user && !user.mfa_active &&
+ mfaAuthServices.indexOf(user.auth_service) !== -1) {
+ return true;
+ }
+ }
+
+ return false;
+}