Skip to content

Commit

Permalink
Merge pull request #281 from JonasNilson/fix/sign-out
Browse files Browse the repository at this point in the history
Fix/sign out
  • Loading branch information
JonasNilson authored Mar 26, 2022
2 parents c9d195e + 0909738 commit c5a8cae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Source/IdleMasterExtended/frmBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ namespace IdleMasterExtended
{
public partial class frmBrowser : Form
{
const int INTERNET_OPTION_END_BROWSER_SESSION = 42;
const int INTERNET_OPTION_SUPPRESS_BEHAVIOR = 81;
const int INTERNET_SUPPRESS_COOKIE_PERSIST = 3;

public int SecondsWaiting = 300;

[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool InternetSetOption(int hInternet, int dwOption, string lpBuffer, int dwBufferLength);
private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, in int flag, int dwBufferLength);

[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool InternetSetCookie(string lpszUrlName, string lpszCookieName, string lpszCookieData);
Expand All @@ -32,7 +35,12 @@ private void frmBrowser_Load(object sender, EventArgs e)
browserBarVisibility(false);

// Remove any existing session state data
InternetSetOption(0, 42, null, 0);
if (!InternetSetOption(IntPtr.Zero, INTERNET_OPTION_END_BROWSER_SESSION, 0, 0)
|| !InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SUPPRESS_BEHAVIOR, INTERNET_SUPPRESS_COOKIE_PERSIST, sizeof(int)))
{
var ex = Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error());
Logger.Exception(ex, "Browser session data could not be reset.");
}

// Localize form
this.Text = localization.strings.please_login;
Expand All @@ -45,7 +53,7 @@ private void frmBrowser_Load(object sender, EventArgs e)
InternetSetCookie("https://steamcommunity.com", "steamRememberLogin", ";expires=Mon, 01 Jan 0001 00:00:00 GMT");

// When the form is loaded, navigate to the Steam login page using the web browser control
webBrowserAuthentication.Navigate("https://steamcommunity.com/login/home/?goto=my/profile", "_self", null, "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko");
webBrowserAuthentication.Navigate("https://steamcommunity.com/login/home/?goto=my/profile", "_self", null, "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko");

this.BackColor = Settings.Default.customTheme ? Settings.Default.colorBgd : Settings.Default.colorBgdOriginal;
this.ForeColor = Settings.Default.customTheme ? Settings.Default.colorTxt : Settings.Default.colorTxtOriginal;
Expand Down
2 changes: 2 additions & 0 deletions Source/IdleMasterExtended/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,8 @@ private void ResetClientStatus()
Settings.Default.sessionid = string.Empty;
Settings.Default.steamLogin = string.Empty;
Settings.Default.steamLoginSecure = string.Empty;
Settings.Default.steamMachineAuth = string.Empty;
Settings.Default.steamRememberLogin = string.Empty;
Settings.Default.myProfileURL = string.Empty;
Settings.Default.steamparental = string.Empty;
Settings.Default.Save();
Expand Down

0 comments on commit c5a8cae

Please sign in to comment.