예제 #1
0
        private async Task <User> GetUser()
        {
            var userName = _claimsService.GetUserName();
            var user     = await _context.Users.FirstOrDefaultAsync(u => u.UserName == userName).ConfigureAwait(false);

            if (user is null)
            {
                user = new User()
                {
                    UserName = userName
                };
                _context.Users.Add(user);
            }

            return(user);
        }
        // Maps to GET http://url/User
        // Allows any authenticated user
        public IActionResult Get()
        {
            var name = claimsService.GetUserName(User);

            return(Ok($"Welcome, {name}"));
        }
        public IActionResult Get()
        {
            var name = claimsService.GetUserName(HttpContext.User);

            return(Ok($"Welcome {name}"));
        }