@@ -36,13 +36,12 @@ public TrayMenu()
3636 debugTools . MenuItems . Add ( currentGame ) ;
3737
3838 trayMenu . MenuItems . Add ( "Better Overwatch v" + Vars . initalize . Version ) ;
39- trayMenu . MenuItems . Add ( "Login " , Login ) ;
39+ trayMenu . MenuItems . Add ( "Logout " , LoginLogout ) ;
4040 trayMenu . MenuItems . Add ( "-" ) ;
4141 trayMenu . MenuItems . Add ( "Upload screenshot of player list" , ToggleUpload ) ;
4242 trayMenu . MenuItems . Add ( "Start with Windows" , ToggleWindows ) ;
4343 trayMenu . MenuItems . Add ( "-" ) ;
4444 trayMenu . MenuItems . Add ( debugTools ) ;
45- trayMenu . MenuItems . Add ( "Logout" , Logout ) ;
4645 trayMenu . MenuItems . Add ( "Exit" , OnExit ) ;
4746 trayMenu . MenuItems [ 0 ] . Enabled = false ;
4847
@@ -156,19 +155,24 @@ private void OpenMatchHistory(object sender, EventArgs e)
156155 Process . Start ( "http://" + Vars . initalize . Host + "/user/" + Vars . settings . publicToken ) ;
157156 }
158157 }
159- private async void Login ( object sender , EventArgs e )
158+ private async void LoginLogout ( object sender , EventArgs e )
160159 {
161- Process . Start ( "https://eu.battle.net/oauth/authorize?response_type=code&client_id=20d78829a4e641e694d8ec7f1198dc8b&redirect_uri=http://betteroverwatch.com/api/authorize/" ) ;
162- await Server . StartLocalAuthServer ( ) ;
163- }
164- private void Logout ( object sender , EventArgs e )
165- {
166- File . Delete ( Path . Combine ( Vars . configPath , "settings.json" ) ) ;
167- Vars . settings = new Settings ( ) ;
168- Program . captureDesktop = false ;
169- Program . authorizeForm = new AuthorizeForm ( ) ;
170- Program . authorizeForm . textLabel . Text = "Logout successful and settings cleared\r \n \r \n You must authorize to continue using Better Overwatch" ;
171- Program . authorizeForm . Show ( ) ;
160+ if ( trayMenu . MenuItems [ 1 ] . Text . Equals ( "Login" ) )
161+ {
162+ Process . Start ( "https://eu.battle.net/oauth/authorize?response_type=code&client_id=20d78829a4e641e694d8ec7f1198dc8b&redirect_uri=http://betteroverwatch.com/api/authorize/" ) ;
163+ await Server . StartLocalAuthServer ( ) ;
164+ }
165+ else
166+ {
167+ trayMenu . MenuItems [ 1 ] . Text = "Login" ;
168+ Process . Start ( "http://betteroverwatch.com/logout.php" ) ;
169+ File . Delete ( Path . Combine ( Vars . configPath , "settings.json" ) ) ;
170+ Vars . settings = new Settings ( ) ;
171+ Program . captureDesktop = false ;
172+ Program . authorizeForm = new AuthorizeForm ( ) ;
173+ Program . authorizeForm . textLabel . Text = "Logout successful and settings cleared\r \n \r \n You must authorize to continue using Better Overwatch" ;
174+ Program . authorizeForm . Show ( ) ;
175+ }
172176 }
173177 public void ChangeTray ( string text , Icon icon )
174178 {
0 commit comments