示例#1
0
        public async Task <IActionResult> OnPostDeleteTokenAsync()
        {
            if (TokenId < 1)
            {
                return(BadRequest("Invalid Token Id"));
            }

            ApplicationUser user = await UserManager.GetUserAsync(User);

            try
            {
                ApplicationUserPersonalAccessToken token = await Context.Set <ApplicationUserPersonalAccessToken>()
                                                           .Where(t => t.ApplicationUserId == user.Id && t.Id == TokenId)
                                                           .SingleAsync();

                Context.Remove(token);
                await Context.SaveChangesAsync();

                Message = "Token deleted.";
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "Unable to delete token.");
                Error = "Unable to delete token.";
            }

            return(RedirectToPage());
        }
示例#2
0
        public async Task <IActionResult> OnPostDeleteTokenAsync()
        {
            ApplicationUser user = await UserManager.GetUserAsync(User);

            try
            {
                ApplicationUserPersonalAccessToken token = await Context.Set <ApplicationUserPersonalAccessToken>()
                                                           .Where(t => t.ApplicationUserId == user.Id && t.Name == TokenName)
                                                           .SingleAsync();

                Context.Remove(token);
                await Context.SaveChangesAsync();
            }
            catch (Exception)
            {
                Error = "Unable to delete token.";
            }

            Tokens = await GetTokens(user);

            return(Page());
        }