Exemplo n.º 1
0
        public IActionResult Delete()
        {
            var jti = User.FindFirst("jti")?.Value;
            var exp = TokenOperator.UnixTimeStampToDateTime(User.FindFirst("exp")?.Value);

            if (jti == null)
            {
                return(NotFound());
            }
            _deletedTokenCache.DeleteToken(new DeletedToken
            {
                Jti = jti,
                Exp = exp
            });
            //_deletedTokenRepository.DeleteToken(new DeletedToken
            //{
            //    Jti = jti,
            //    Exp = exp
            //});
            //if (!_deletedTokenRepository.Save())
            //{
            //    return StatusCode(500, "将token失效信息存入数据库时出错");
            //}
            return(NoContent());
        }
Exemplo n.º 2
0
        public ActionResult Get()
        {
            _logger.LogDebug("Get Values From Token.");
            var jti        = User.FindFirst("jti")?.Value;
            var company    = User.FindFirst("company")?.Value;
            var department = User.FindFirst("department")?.Value;
            var position   = User.FindFirst("position")?.Value;
            var expstring  = User.FindFirst("exp")?.Value;
            var exp        = TokenOperator.UnixTimeStampToDateTime(expstring);

            if (jti == null)
            {
                return(NotFound());
            }

            // save jti (and username) into database

            return(Ok(jti + ", expire:" + exp + ", company:" + company + ", department:" + department + ", position:" + position));
        }