From f9a3a4b3949dddecae413b97904c895b2cd887bf Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Wed, 30 Mar 2016 12:49:29 -0400
Subject: Add MFA functionality

---
 .../components/admin_console/service_settings.jsx  | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)

(limited to 'webapp/components/admin_console/service_settings.jsx')

diff --git a/webapp/components/admin_console/service_settings.jsx b/webapp/components/admin_console/service_settings.jsx
index 881d22d76..41ea5ea34 100644
--- a/webapp/components/admin_console/service_settings.jsx
+++ b/webapp/components/admin_console/service_settings.jsx
@@ -84,6 +84,7 @@ class ServiceSettings extends React.Component {
         config.ServiceSettings.EnableDeveloper = ReactDOM.findDOMNode(this.refs.EnableDeveloper).checked;
         config.ServiceSettings.EnableSecurityFixAlert = ReactDOM.findDOMNode(this.refs.EnableSecurityFixAlert).checked;
         config.ServiceSettings.EnableInsecureOutgoingConnections = ReactDOM.findDOMNode(this.refs.EnableInsecureOutgoingConnections).checked;
+        config.ServiceSettings.EnableMultifactorAuthentication = ReactDOM.findDOMNode(this.refs.EnableMultifactorAuthentication).checked;
         config.ServiceSettings.EnableCommands = ReactDOM.findDOMNode(this.refs.EnableCommands).checked;
         config.ServiceSettings.EnableOnlyAdminIntegrations = ReactDOM.findDOMNode(this.refs.EnableOnlyAdminIntegrations).checked;
 
@@ -173,6 +174,58 @@ class ServiceSettings extends React.Component {
             saveClass = 'btn btn-primary';
         }
 
+        let mfaSetting;
+        if (global.window.mm_license.IsLicensed === 'true' && global.window.mm_license.MFA === 'true') {
+            mfaSetting = (
+                <div className='form-group'>
+                    <label
+                        className='control-label col-sm-4'
+                        htmlFor='EnableMultifactorAuthentication'
+                    >
+                        <FormattedMessage
+                            id='admin.service.mfaTitle'
+                            defaultMessage='Enable Multi-factor Authentication:'
+                        />
+                    </label>
+                    <div className='col-sm-8'>
+                        <label className='radio-inline'>
+                            <input
+                                type='radio'
+                                name='EnableMultifactorAuthentication'
+                                value='true'
+                                ref='EnableMultifactorAuthentication'
+                                defaultChecked={this.props.config.ServiceSettings.EnableMultifactorAuthentication}
+                                onChange={this.handleChange}
+                            />
+                            <FormattedMessage
+                                id='admin.service.true'
+                                defaultMessage='true'
+                            />
+                        </label>
+                        <label className='radio-inline'>
+                            <input
+                                type='radio'
+                                name='EnableMultifactorAuthentication'
+                                value='false'
+                                defaultChecked={!this.props.config.ServiceSettings.EnableMultifactorAuthentication}
+                                onChange={this.handleChange}
+                            />
+                            <FormattedMessage
+                                id='admin.service.false'
+                                defaultMessage='false'
+                            />
+                        </label>
+                        <p className='help-text'>
+                            <FormattedMessage
+                                id='admin.service.mfaDesc'
+                                defaultMessage='When true, users will be given the option to add multi-factor authentication to their account. They will need a smartphone and an authenticator app such as Google Authenticator.'
+                            />
+                        </p>
+                    </div>
+                </div>
+            );
+        }
+
         return (
             <div className='wrapper--fixed'>
 
@@ -773,6 +826,8 @@ class ServiceSettings extends React.Component {
                         </div>
                     </div>
 
+                    {mfaSetting}
+
                     <div className='form-group'>
                         <label
                             className='control-label col-sm-4'
-- 
cgit v1.2.3-1-g7c22

