예제 #1
0
        public async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
        {
            var allowedOrigin = context.OwinContext.Get <string>("ou:clientAllowedOrigin");

            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { allowedOrigin });

            string hashedTokenId = Utility.GetHash(context.Token);

            using (RefreshTokenRepository _refreshTokenRepository = new RefreshTokenRepository())
            {
                var refreshToken = await _refreshTokenRepository.FindRefreshToken(hashedTokenId);

                if (refreshToken != null)
                {
                    context.DeserializeTicket(refreshToken.ProtectedTicket);
                    await _refreshTokenRepository.RemoveRefreshToken(hashedTokenId);
                }
            }
        }
        public async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
        {
            var allowedOrigin = context.OwinContext.Get<string>("as:clientAllowedOrigin");
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { allowedOrigin });

            string hashedTokenId = context.Token.GetHash();
            using(UnitOfWork uow = new UnitOfWork())
            {
                using (RefreshTokenRepository _repo = new RefreshTokenRepository(uow))
                {
                    var refreshToken = await _repo.FindRefreshToken(hashedTokenId);

                    if (refreshToken != null)
                    {
                        //Get protectedTicket from refreshToken class
                        context.DeserializeTicket(refreshToken.ProtectedTicket);
                        var result = await _repo.RemoveRefreshToken(hashedTokenId);
                    }
                }
            }
            
        }
        public async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
        {
            var allowedOrigin = context.OwinContext.Get <string>("as:clientAllowedOrigin");

            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { allowedOrigin });

            string hashedTokenId = context.Token.GetHash();

            using (UnitOfWork uow = new UnitOfWork())
            {
                using (RefreshTokenRepository _repo = new RefreshTokenRepository(uow))
                {
                    var refreshToken = await _repo.FindRefreshToken(hashedTokenId);

                    if (refreshToken != null)
                    {
                        //Get protectedTicket from refreshToken class
                        context.DeserializeTicket(refreshToken.ProtectedTicket);
                        var result = await _repo.RemoveRefreshToken(hashedTokenId);
                    }
                }
            }
        }