Пример #1
0
        public NoteController(UserNotesDbContext context, IHttpContextAccessor httpContextAccessor)
        {
            _Context = context;
            var user = httpContextAccessor?.HttpContext?.User;

            if (user != null)
            {
                var userIdString  = user.FindFirst(ClaimTypes.NameIdentifier)?.Value;
                var isAdminString = user.FindFirst(ClaimTypes.Role)?.Value;

                if (userIdString != null)
                {
                    _CurrentUserId = Convert.ToInt32(userIdString);
                }
                _AdminMode = isAdminString == "admin";
            }
        }
 public AuthController(UserNotesDbContext context)
 {
     _Context = context;
 }