/// <summary> /// Logs the user out, removes their current device if the removeDevice flag is set, and handles local files cleanup. /// Note: Removing a device will also effectively invalidate the user's current FxA token. /// </summary> /// <param name="removeDevice">Optional: Indicates the removal of the current user's device when set to true.</param> public void Logout(bool removeDevice = false) { try { // Disconnect the VPN tunnel Manager.Tunnel.Disconnect(false); // Remove the current account device if (removeDevice) { var devices = new FxA.Devices(); devices.RemoveDevice(Manager.Account.Config.FxALogin.PublicKey, silent: true); } } catch (Exception) { ErrorHandler.Handle(new UserFacingMessage("toast-remove-device-error"), UserFacingErrorType.Toast, UserFacingSeverity.ShowWarning, LogLevel.Debug); } finally { // Clear up login session files from user's appdata folder Config.RemoveFxAToken(); File.Delete(ProductConstants.FxAUserFile); File.Delete(ProductConstants.FirefoxPrivateNetworkConfFile); // Set logged out state and terminate UI Updater threads LoginState = LoginState.LoggedOut; Manager.TerminateUIUpdaters(); } }
/// <summary> /// Remove device. /// </summary> /// <param name="req">WCF device request.</param> /// <returns>WCF response.</returns> public Response RemoveDevice(DeviceRequest req) { try { var devices = new FxA.Devices(); devices.RemoveDevice(req.PublicKey, false, true); return(new Response(200, "Success")); } catch (Exception ex) { return(new Response(500, ex.Message)); } }