public ActionResult Logar(string Login, string Password, int?id) { try { using (RepositoryUser rep = new RepositoryUser()) { Func <UserEntity, bool> predicate = (u => u.Login == Login && u.Password == Password); UserEntity user = rep.Get(predicate).FirstOrDefault(); if (user == null) { ViewData["Error"] = "Login e/ou senha inválidos."; return(View("Login")); } user.Password = String.Empty; Session["ID"] = user.ID; Session["Login"] = user.Login; Session["Nome"] = user.First_name + " " + user.Last_name; Session["Logado"] = "logado"; if (id != null) { return(RedirectToAction("AdicionarCarrinho", "Cart", new { id })); } return(RedirectToAction("Index", "Product")); } } catch (Exception) { ViewBag.Error = "Login e/ou senha incorretos. Verifique!"; return(View("Index")); } }
public void ResetPassword(int ID) { var objRepo = new RepositoryUser(); var dataUsuario = objRepo.Get(ID); if (dataUsuario == null) { throw new Exception("UserInvalid"); } var NewPassword = GeneratePassword(8); dataUsuario.Password = new BusinessCryptoMD5(GlobalConfiguration.CryptoKey).CryptoString(NewPassword); dataUsuario.ChangePassword = true; objRepo.Update(dataUsuario); List <string> arr = new List <string>(); arr.Add(dataUsuario.Email); var objAlerta = new BusinessNotification(); byte[] outMessage = new byte[ResourceMessage.GetStream("NotificationRecoveryBodyContent").Length]; ResourceMessage.GetStream("NotificationRecoveryBodyContent").Read(outMessage, 0, (int)ResourceMessage.GetStream("NotificationRecoveryBodyContent").Length); StringBuilder sb = new StringBuilder(UnicodeEncoding.Unicode.GetString(outMessage)); sb = sb.Replace("#%Nombre%#", dataUsuario.Name); sb = sb.Replace("#%ClaveTemporal%#", NewPassword); //objAlerta.SendMails(arr, ResourceMessage.GetString("NotificationRecoveryPassword"), sb.ToString()); objAlerta.SendMailExchange(GlobalConfiguration.exchangeUser, GlobalConfiguration.exchangePwd, arr, ResourceMessage.GetString("NotificationRecoveryPassword"), sb.ToString()); }
public UserEntity GetCredentials(String login, String password) { UserEntity user; using (RepositoryUser rep = new RepositoryUser()) { Func <UserEntity, bool> predicate = (p => p.Login == login && p.Password == password); user = rep.Get(predicate).FirstOrDefault <UserEntity>(); if (user != null) { user.Password = String.Empty; return(user); } return(null); } }
public List <User> Get() { return(_repo.Get()); }