public async Task <IActionResult> Register(Account Account) { var account = await UserMng .FindByEmailAsync(Account.Email); if (ModelState.IsValid && account == null) { var result = await UserMng.CreateAsync(Account); var result1 = await UserMng.AddToRoleAsync(Account, "Customer"); if (result.Succeeded && result1.Succeeded) { await SignMng.SignInAsync(Account, isPersistent : false); return(RedirectToAction("Index", "Home")); } else { ViewBag.UserNameDublicated = "Your UserName is Dublicated ..."; return(View(Account)); } } ViewBag.EmailExist = "This Email is Exist ..."; return(View(Account)); }
public async Task <IActionResult> Login(Account Account) { var account = await _context.Users .FirstOrDefaultAsync(m => m.Email == Account.Email); if (account != null && account.Password == Account.Password) { await SignMng.SignInAsync(account, isPersistent : false); return(RedirectToAction("Index", "Home")); } ViewBag.InputValid = "Check Your Email or Password ..."; return(View(Account)); }
// return view for logout User // written By khalil Email: [email protected] public async Task <IActionResult> LogOut() { await SignMng.SignOutAsync(); return(RedirectToAction("Index", "Home")); }