Exemple #1
0
        public User GetCurrentUser()
        {
            string       token   = Request.Headers["Authorization"];
            JwtTokenUtil jwtUtil = new JwtTokenUtil(_configuration);
            long         userid  = jwtUtil.DecodeToken(token);
            User         user    = _context.User.Find(userid);

            if (user == null)
            {
                throw new Exception("不存在用户!");
            }
            return(user);
        }