diff --git a/app/mobile/src/access/admin/useAdmin.hook.js b/app/mobile/src/access/admin/useAdmin.hook.js
index 1e28c9d1..78615aa4 100644
--- a/app/mobile/src/access/admin/useAdmin.hook.js
+++ b/app/mobile/src/access/admin/useAdmin.hook.js
@@ -2,8 +2,10 @@ import { useState, useEffect, useContext } from 'react';
import { useWindowDimensions } from 'react-native';
import { useNavigate } from 'react-router-dom';
import { AppContext } from 'context/AppContext';
+import { getNodeStatus } from 'api/getNodeStatus';
import { setNodeStatus } from 'api/setNodeStatus';
import { setNodeAccess } from 'api/setNodeAccess';
+import { getNodeConfig } from 'api/getNodeConfig';
import { getLanguageStrings } from 'constants/Strings';
export function useAdmin() {
@@ -90,16 +92,23 @@ export function useAdmin() {
try {
const session = await setNodeAccess(node, state.token, state.mfaCode);
updateState({ server: node, busy: false });
- navigate('/dashboard', { state: { server: node, token: session }});
+ navigate('/dashboard', { state: { server: node, token: session, mfa: true }});
}
catch (err) {
if (err.message == '405' || err.message == '403' || err.message == '429') {
updateState({ mfaModal: true, mfaError: err.message });
}
else {
- console.log(err.message);
- updateState({ busy: false, showAlert: true });
- throw new Error('login failed');
+ try {
+ await getNodeConfig(node, state.token);
+ updateState({ server: node, busy: false });
+ navigate('/dashboard', { state: { server: node, token: state.token, mfa: false }});
+ }
+ catch (err) {
+ console.log(err.message);
+ updateState({ busy: false, showAlert: true });
+ throw new Error('login failed');
+ }
}
}
}
diff --git a/app/mobile/src/dashboard/Dashboard.jsx b/app/mobile/src/dashboard/Dashboard.jsx
index 15e82e62..5949c313 100644
--- a/app/mobile/src/dashboard/Dashboard.jsx
+++ b/app/mobile/src/dashboard/Dashboard.jsx
@@ -15,8 +15,8 @@ import { InputCode } from 'utils/InputCode';
export function Dashboard(props) {
const location = useLocation();
- const { server, token } = location.state;
- const { state, actions } = useDashboard(server, token);
+ const { server, token, mfa } = location.state;
+ const { state, actions } = useDashboard(server, token, mfa);
const enableMFA = async () => {
try {
@@ -121,12 +121,12 @@ export function Dashboard(props) {
- { !state.mfaEnabled && (
+ { !state.mfaEnabled && mfa && (
)}
- { state.mfaEnabled && (
+ { state.mfaEnabled && mfa && (
diff --git a/app/mobile/src/dashboard/useDashboard.hook.js b/app/mobile/src/dashboard/useDashboard.hook.js
index 2342505d..2a5b95e5 100644
--- a/app/mobile/src/dashboard/useDashboard.hook.js
+++ b/app/mobile/src/dashboard/useDashboard.hook.js
@@ -20,7 +20,7 @@ import { addAdminMFAuth } from 'api/addAdminMFAuth';
import { setAdminMFAuth } from 'api/setAdminMFAuth';
import { removeAdminMFAuth } from 'api/removeAdminMFAuth';
-export function useDashboard(server, token) {
+export function useDashboard(server, token, mfa) {
const [state, setState] = useState({
strings: getLanguageStrings(),
@@ -74,7 +74,7 @@ export function useDashboard(server, token) {
}
const syncNode = async () => {
- const mfaEnabled = await getAdminMFAuth(server, token);
+ const mfaEnabled = mfa ? await getAdminMFAuth(server, token) : false;
const config = await getNodeConfig(server, token);
const nodeAccounts = await getNodeAccounts(server, token);
const accounts = nodeAccounts.map(setAccountItem);