Esempio n. 1
0
        public async Task<JsonResult> Login(LoginModel model)
        {
            if (!ModelState.IsValid)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return Json(ModelState.Errors());
            }
            ClaimsIdentity claim = await _userProfileService.Autorization(Mapper.ToBllUserProfileLoginModel(model));

                if (claim != null)
                {
                    AuthenticationManager.SignOut();
                    AuthenticationManager.SignIn(new AuthenticationProperties
                    {
                        IsPersistent = true
                    }, claim);
                    return Json(new HttpResponseMessage(HttpStatusCode.NoContent));
                }
                ModelState.AddModelError("Error", "Incorrect login or password");
            Response.StatusCode = (int)HttpStatusCode.BadRequest;
            return Json(ModelState.Errors());
        }
Esempio n. 2
0
 internal static BllUserProfile ToBllUserProfileLoginModel(LoginModel model)
 {
     if (model != null)
         return new BllUserProfile
         {
             Email = model.Email,
             Name = model.Name,
             Password = model.Password
         };
     return null;
 }