public override bool ChangePassword(string username, string oldPassword, string newPassword) { if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(oldPassword) || string.IsNullOrEmpty(newPassword)) { return(false); } if (oldPassword == newPassword) { return(false); } CadeMeuMedicoMembershipUser user = GetUser(username); if (user == null) { return(false); } ContextoUsuario db = new ContextoUsuario(); var RawUser = (from u in db.Usuarios where u.Login == user.UserName select u).FirstOrDefault(); if (string.IsNullOrWhiteSpace(RawUser.Senha)) { return(false); } RawUser.Senha = EncodePassword(newPassword); db.SaveChanges(); return(true); }
public CadeMeuMedicoMembershipUser CreateUser( string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status, string nome ) { ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, password, true); OnValidatingPassword(args); if (args.Cancel) { status = MembershipCreateStatus.InvalidPassword; return(null); } if ((RequiresUniqueEmail && (GetUserNameByEmail(email) != String.Empty))) { status = MembershipCreateStatus.DuplicateEmail; return(null); } CadeMeuMedicoMembershipUser cadeMeuMedicoMembershipUser = GetUser(username); if (cadeMeuMedicoMembershipUser == null) { try { using (ContextoUsuario _db = new ContextoUsuario()) { Usuario user = new Usuario(); user.Nome = nome; user.Login = username; user.Senha = EncodePassword(password); user.Email = email.ToLower(); _db.Usuarios.Add(user); _db.SaveChanges(); status = MembershipCreateStatus.Success; return(GetUser(username)); } } catch { status = MembershipCreateStatus.ProviderError; } } else { status = MembershipCreateStatus.DuplicateUserName; } return(null); }
public void UpdateCadeMeuMedicoUser(CadeMeuMedicoMembershipUser user) { using (ContextoUsuario _db = new ContextoUsuario()) { try { Usuario userToEdit = (from u in _db.Usuarios where u.Login == user.UserName select u).FirstOrDefault(); if (userToEdit != null) { userToEdit.Nome = user.Nome; userToEdit.Email = user.Email; _db.SaveChanges(); } } catch { } } }
public CadeMeuMedicoMembershipUser GetUser(string username) { CadeMeuMedicoMembershipUser cadeMeuMedicoMembershipUser = null; using (ContextoUsuario _db = new ContextoUsuario()) { try { Usuario user = (from u in _db.Usuarios where u.Login == username select u).FirstOrDefault(); if (user != null) { cadeMeuMedicoMembershipUser = new CadeMeuMedicoMembershipUser( this.Name, user.Login, null, user.Email, "", "", true, false, default(DateTime), DateTime.Now, DateTime.Now, default(DateTime), default(DateTime), user.Nome); } } catch {} } return(cadeMeuMedicoMembershipUser); }