Пример #1
0
        public async Task <IActionResult> Authenticate([FromBody] Authenticate authModel)
        {
            var user = await _patientService.AuthenticateAsync(authModel.name, authModel.password);

            if (user == null)
            {
                return(BadRequest(new { message = "Username or password is incorrect" }));
            }
            return(Ok(user));
        }
Пример #2
0
        public async Task <ActionResult> Authenticate([FromBody] AuthenticateModel model)
        {
            string token = await _patientService.AuthenticateAsync(model.Username, model.Password);



            if (token == null)
            {
                return(BadRequest(new { message = "Username or password is incorrect" }));
            }
            else
            {
                HttpContext.Response.Cookies.Append(".AspNetCore.Application.Id", token,
                                                    new CookieOptions
                {
                    MaxAge = TimeSpan.FromMinutes(60)
                });
                return(Ok());
            }
        }