private async void SingInout_Click(object sender, EventArgs e) { try { this.btnSingInout.Enabled = false; if (this.signedInuser != null) { ToolAuthentication.SignOut(); this.signedInuser = null; } else { DevAccountSource accountSource = DevAccountSource.WindowsDevCenter; this.signedInuser = await ToolAuthentication.SignInAsync(accountSource, null); } } catch (Exception exception) { MessageBox.Show(exception.Message, "Error"); } finally { this.UpdateAccountPanel(); this.btnSingInout.Enabled = true; } }
public async Task LoadSignedInUser() { // Clear cache and signed in user info. if (ToolAuthentication.LoadLastSignedInUser() != null) { ToolAuthentication.SignOut(); } var mockHttp = new MockHttpMessageHandler(); this.ComposeETokenPayload(new TimeSpan(1, 0, 0), string.Empty, string.Empty, out string defaultRequest, out string defaultXdtsResponse); mockHttp.Expect(DefaultXtdsEndpoint) .WithContent(defaultRequest) .Respond("application/json", defaultXdtsResponse); TestHook.MockHttpHandler = mockHttp; var devAccount = await this.SignInAsync(DevAccountSource.WindowsDevCenter, string.Empty); var devAccountToVerify = ToolAuthentication.LoadLastSignedInUser(); Assert.AreEqual(devAccount.AccountId, devAccountToVerify.AccountId); Assert.AreEqual(devAccount.AccountMoniker, devAccountToVerify.AccountMoniker); Assert.AreEqual(devAccount.AccountSource, devAccountToVerify.AccountSource); Assert.AreEqual(devAccount.AccountType, devAccountToVerify.AccountType); Assert.AreEqual(devAccount.Id, devAccountToVerify.Id); Assert.AreEqual(devAccount.Name, devAccountToVerify.Name); }
/// <inheritdoc/> protected override void Process() { DevAccount account = ToolAuthentication.LoadLastSignedInUser(); if (account != null) { ToolAuthentication.SignOut(); this.WriteObject($"Developer account {account.Name} from {account.AccountSource} has successfully signed out."); } else { this.WriteObject($"No signed in account found."); } }
private static int OnSignOut() { DevAccount account = ToolAuthentication.LoadLastSignedInUser(); if (account != null) { ToolAuthentication.SignOut(); Console.WriteLine($"Developer account {account.Name} from {account.AccountSource} has successfully signed out."); return(0); } else { Console.WriteLine($"No signed in account found."); return(-1); } }
public void TestCleanup() { TestHook.MockHttpHandler = null; ToolAuthentication.SignOut(); }