Exemplo n.º 1
0
 public UserViewModel(User user)
 {
     Id                  = user.Id;
     FirstName           = user.FirstName;
     LastName            = user.LastName;
     Company             = user.Company;
     IsAdmin             = user.IsAdmin;
     IsCarwashAdmin      = user.IsCarwashAdmin;
     CalendarIntegration = user.CalendarIntegration;
     NotificationChannel = user.NotificationChannel;
 }
Exemplo n.º 2
0
        /// <inheritdoc />
        public UsersController(ApplicationDbContext context, IHttpContextAccessor httpContextAccessor, IEmailService emailService)
        {
            _context      = context;
            _emailService = emailService;

            var email = httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.Upn)?.ToLower() ??
                        httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.Email)?.ToLower();

            // Check if request is coming from an authorized service application.
            var serviceAppId = httpContextAccessor.HttpContext.User.FindFirstValue("appid");

            if (serviceAppId != null && email == null)
            {
                return;
            }

            if (email == null)
            {
                throw new Exception("Email ('upn' or 'email') cannot be found in auth token.");
            }

            _user = _context.Users.SingleOrDefault(u => u.Email == email);
        }