public async Task <bool> Logout(string userId, string refreshToken)
        {
            await _tokenService.RevokeUserBearerTokensAsync(userId, refreshToken);

            _antiForgeryCookieService.DeleteAntiForgeryCookies();

            return(true);
        }
Example #2
0
        public async Task <bool> LogoutAsync(string refreshToken)
        {
            var claimsIdentity = _httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity;
            var userIdValue    = claimsIdentity.FindFirst(ClaimTypes.UserData)?.Value;
            await _userTokenStorageService.RevokeUserBearerTokensAsync(userIdValue, refreshToken);

            await _unitOfWork.SaveChangesAsync();

            _antiForgeryCookieService.DeleteAntiForgeryCookies();
            return(true);
        }
        public async Task <IActionResult> logout()
        {
            try
            {
                await _userService.Logout();

                _antiforgery.DeleteAntiForgeryCookies();
                //HttpContext.Session.Clear();
                return(Json(new HttpResult()
                {
                    Success = true, Data = null, Message = "با موفقیت انجام شد"
                }));
            }
            catch (Exception ex) {
                return(Json(new HttpResult()
                {
                    Success = false, Data = null, Message = "مشکلی در انجام عملیات وجود دارد"
                }));
            }
        }
        public async Task <bool> Logout(string refreshToken)
        {
            var claimsIdentity = this.User.Identity as ClaimsIdentity;
            var userIdValue    = claimsIdentity.FindFirst(ClaimTypes.UserData)?.Value;

            // The Jwt implementation does not support "revoke OAuth token" (logout) by design.
            // Delete the user's tokens from the database (revoke its bearer token)
            await _tokenStoreService.RevokeUserBearerTokensAsync(userIdValue, refreshToken);

            _antiforgery.DeleteAntiForgeryCookies();

            return(true);
        }
        /// <summary>
        /// The Jwt implementation does not support "revoke OAuth token" (logout) by design.
        /// Delete the user's tokens from the database (revoke its bearer token)
        /// </summary>
        public async Task SignOutAsync()
        {
            await _tokenManager.RevokeTokensAsync(_session.UserId);

            _antiForgery.DeleteAntiForgeryCookies();
        }