public async Task <IActionResult> Get(string token, string userId, string returnUrl = "/") { var user = barberRepository.GetBarberById(userId); if (user == null) { return(Unauthorized()); } var claims = new List <Claim> { new Claim(ClaimTypes.NameIdentifier, user.id.ToString()), new Claim(ClaimTypes.Name, user.Name), new Claim(ClaimTypes.Role, user.Role) }; var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var principal = new ClaimsPrincipal(identity); await HttpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, principal, new AuthenticationProperties { IsPersistent = false }); return(LocalRedirect(returnUrl)); }
public IActionResult GetBarber(string barberId) { var barber = barberRepository.GetBarberById(barberId); if (barber == null) { return(NotFound()); } return(Content(JsonConvert.SerializeObject(barber))); }