diff --git a/src/MainForm.cs b/src/MainForm.cs index cbe586c..c8a0554 100644 --- a/src/MainForm.cs +++ b/src/MainForm.cs @@ -1076,6 +1076,7 @@ namespace MeshCentralRouter cookieRefreshTimer.Enabled = true; // If we need to remember the 2nd factor, ask for a cookie now. + if (debug) { try { File.AppendAllText("debug.log", "Requesting 2FA cookie\r\n"); } catch (Exception) { } } if (tokenRememberCheckBox.Checked) { meshcentral.sendCommand("{\"action\":\"twoFactorCookie\"}"); } // Setup single instance pipe server diff --git a/src/MeshCentralServer.cs b/src/MeshCentralServer.cs index a2363e7..b9a0adb 100644 --- a/src/MeshCentralServer.cs +++ b/src/MeshCentralServer.cs @@ -676,8 +676,11 @@ namespace MeshCentralRouter { if (jsonAction.ContainsKey("cookie")) { - string cookie = (string)jsonAction["cookie"]; - if (onTwoFactorCookie != null) { onTwoFactorCookie(cookie); } + if (jsonAction["cookie"] == null) return; + if (jsonAction["cookie"].GetType() != typeof(string)) return; + string cookie = null; + try { cookie = (string)jsonAction["cookie"]; } catch (Exception) { } + if ((cookie != null) && (onTwoFactorCookie != null)) { onTwoFactorCookie(cookie); } } break; }