From f2e788f4b12517759e016a9f48633597bed82e8f Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Thu, 5 May 2016 16:36:42 -0400
Subject: Allow system admins to switch user accounts to email/password (#2893)

---
 webapp/components/admin_console/user_item.jsx | 48 ++++++++++++++++++++-------
 1 file changed, 36 insertions(+), 12 deletions(-)

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

diff --git a/webapp/components/admin_console/user_item.jsx b/webapp/components/admin_console/user_item.jsx
index b8f21d77e..660f75a41 100644
--- a/webapp/components/admin_console/user_item.jsx
+++ b/webapp/components/admin_console/user_item.jsx
@@ -366,6 +366,7 @@ export default class UserItem extends React.Component {
         }
 
         let authServiceText;
+        let passwordReset;
         if (user.auth_service) {
             authServiceText = (
                 <FormattedHTMLMessage
@@ -376,6 +377,21 @@ export default class UserItem extends React.Component {
                     }}
                 />
             );
+
+            passwordReset = (
+                <li role='presentation'>
+                    <a
+                        role='menuitem'
+                        href='#'
+                        onClick={this.handleResetPassword}
+                    >
+                        <FormattedMessage
+                            id='admin.user_item.switchToEmail'
+                            defaultMessage='Switch to Email/Password'
+                        />
+                    </a>
+                </li>
+            );
         } else {
             authServiceText = (
                 <FormattedHTMLMessage
@@ -383,6 +399,25 @@ export default class UserItem extends React.Component {
                     defaultMessage=', <strong>Sign-in Method:</strong> Email'
                 />
             );
+
+            passwordReset = (
+                <li role='presentation'>
+                    <a
+                        role='menuitem'
+                        href='#'
+                        onClick={this.handleResetPassword}
+                    >
+                        <FormattedMessage
+                            id='admin.user_item.resetPwd'
+                            defaultMessage='Reset Password'
+                        />
+                    </a>
+                </li>
+            );
+        }
+
+        if (global.window.mm_config.EnableSignInWithEmail !== 'true') {
+            passwordReset = null;
         }
 
         const me = UserStore.getCurrentUser();
@@ -474,18 +509,7 @@ export default class UserItem extends React.Component {
                             {makeNotActive}
                             {makeSystemAdmin}
                             {mfaReset}
-                            <li role='presentation'>
-                                <a
-                                    role='menuitem'
-                                    href='#'
-                                    onClick={this.handleResetPassword}
-                                >
-                                    <FormattedMessage
-                                        id='admin.user_item.resetPwd'
-                                        defaultMessage='Reset Password'
-                                    />
-                                </a>
-                            </li>
+                            {passwordReset}
                         </ul>
                     </div>
                 </div>
-- 
cgit v1.2.3-1-g7c22

