示例#1
0
        /// <summary>
        /// Deletes the access token from user's device
        /// </summary>
        /// <returns></returns>
        public async static Task <bool> SignOut(string userId)
        {
            try
            {
                //var vault = new PasswordVault();
                //var credentialList = vault.FindAllByUserName(userId);

                //if (credentialList.Count > 0)
                //{
                //    vault.Remove(credentialList[0]);
                //}
                await AccountsService.SignOutOfAccount(userId);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// Saves access token in device
        /// </summary>
        /// <param name="token"></param>
        /// <param name="clientId">Client Id is used as resource string for PasswordCredential</param>
        /// <returns></returns>
        private async Task <bool> SaveToken(string token, string clientId)
        {
            try
            {
                GlobalHelper.GithubClient = UserService.GetAuthenticatedClient(token);
                User user = await UserService.GetCurrentUserInfo();

                var vault = new PasswordVault();
                vault.Add(new PasswordCredential(clientId, user.Id.ToString(), token));

                await AccountsService.AddUser(new Models.Account {
                    Id = user.Id, AvatarUrl = user.AvatarUrl, IsLoggedIn = true, Login = user.Login, IsActive = true
                });

                return(true);
            }
            catch
            {
                return(false);
            }
        }