public ActionResult Register(AuthenticationParamsViewModel auth) { if (!ModelState.IsValid) { return(View(auth)); } using (var client = new AuthenticationServiceClient()) { if (!client.RegisterUser(auth.User, auth.Password)) { throw new Exception($"Ошибка при регистрации пользователя {auth.User}."); } } FormsAuthentication.SetAuthCookie(auth.User, true); return(RedirectToAction("Catalog", "Home")); }
public ActionResult LogIn(AuthenticationParamsViewModel auth) { if (!ModelState.IsValid) { return(View(auth)); } using (var client = new AuthenticationServiceClient()) { if (!client.CheckUser(auth.User, auth.Password)) { return(View(new AuthenticationParamsViewModel { IsAuthFailed = true, Password = "", User = "" })); } } FormsAuthentication.SetAuthCookie(auth.User, true); return(RedirectToAction("Catalog", "Home")); }