public void Logout() { Account.Dispose(); Account = null; Client = null; MessageBus.Current.SendMessage(new LogoutMessage()); }
public LoginViewModel(INetworkActivityService networkActivity) { LoginCommand = ReactiveCommand.CreateAsyncTask(async t => { var account = new Account(); var connection = new Octokit.Connection(new Octokit.ProductHeaderValue("RepoStumble")); var client = new Octokit.OauthClient(connection); var token = await client.CreateAccessToken(new Octokit.OauthTokenRequest(ClientId, ClientSecret, LoginCode)); connection.Credentials = new Octokit.Credentials(token.AccessToken); var githubClient = new Octokit.GitHubClient(connection); var info = await githubClient.User.Current(); account.AvatarUrl = info.AvatarUrl; account.Username = info.Login; account.Fullname = info.Name; account.OAuth = token.AccessToken; account.Save(); DismissCommand.ExecuteIfCan(); }); LoginCommand.IsExecuting.Skip(1).Where(x => x).Subscribe(x => networkActivity.PushNetworkActive()); LoginCommand.IsExecuting.Skip(1).Where(x => !x).Subscribe(x => networkActivity.PopNetworkActive()); }
public bool Load() { Account = Account.Load(); if (Account == null) return false; var connection = new Octokit.Connection(new Octokit.ProductHeaderValue("RepoStumble")); connection.Credentials = new Octokit.Credentials(Account.OAuth); Client = new Octokit.GitHubClient(connection); LoadLikesFromStars(); return true; }