public override string GetUserNameByEmail(string email) { MembershipUser user = MembershipUserUtility.FindUserByPredicate(p => p.Email == email.Trim()); if (user != null) { return(user.UserName); } else { return(null); } }
public static MembershipUser FindUserByPredicate(this Expression <Func <DataAccess.Login, bool> > predicate) { MembershipUser membershipUser = null; using (var db = new DataAccess.CSSDataContext()) { var login = db.Logins.FirstOrDefault(predicate); if (login != null) { membershipUser = MembershipUserUtility.CreateMembershipUserFromLogin(login); } } return(membershipUser); }
public static MembershipUserCollection FindUsersByPredicate(this Expression <Func <DataAccess.Login, bool> > predicate, int pageIndex, int pageSize, out int totalRecords) { MembershipUserCollection returnValue = new MembershipUserCollection(); totalRecords = 0; using (var db = new DataAccess.CSSDataContext()) { var logins = db.Logins.Where(predicate); totalRecords = logins.Count(); foreach (var login in logins.Skip(pageIndex * pageSize).Take(pageSize)) { returnValue.Add(MembershipUserUtility.CreateMembershipUserFromLogin(login)); } } return(returnValue); }
public override System.Web.Security.MembershipUser GetUser(string username, bool userIsOnline) { // TODO: (Optional) if userIsOnline is true, then the user's last action timestamp may be updated. // the current db schema does not support this column. MembershipUser returnValue = MembershipUserUtility.FindUserByPredicate(p => p.Username == username); if (returnValue == null) { using (CSSDataContext db = new CSSDataContext()) { var login = Login.FindLoginByUsernameOrCallsign(db, username); if (login != null) { returnValue = MembershipUserUtility.FindUserByPredicate(p => p.Username == login.Username); } } } return(returnValue); }
public override System.Web.Security.MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out System.Web.Security.MembershipCreateStatus status) { DataAccess.Identity identity = null; var connect = new Connect(); using (var db = new DataAccess.CSSDataContext()) { if (DataAccess.Login.FindLoginByUsernameOrCallsign(db, username) != null) { status = System.Web.Security.MembershipCreateStatus.DuplicateUserName; return(null); } if (DataAccess.Alias.ListAliases(db, username).Count > 0) { status = System.Web.Security.MembershipCreateStatus.UserRejected; return(null); } if (Settings.Default.UseIPConverge == true) { if (connect.CheckEmail(email) == false) { status = MembershipCreateStatus.DuplicateEmail; return(null); } if (connect.CheckUsername(username) == false) { status = MembershipCreateStatus.DuplicateUserName; return(null); } } status = DataAccess.Identity.TryCreateIdentity(db, username, password, email, out identity); if (status == MembershipCreateStatus.Success) { if (Settings.Default.UseIPConverge == true) { string ipAddress = "127.0.0.1"; if (HttpContext.Current != null) { ipAddress = HttpContext.Current.Request.UserHostAddress; } // TODO: If IP Converge is to be used ever, then working around IPC's MD5 password hashs will need to be done. //if (connect.AddMember(email, username, passwordHash, ipAddress) == false) //{ // status = MembershipCreateStatus.ProviderError; // return null; //} } } db.SubmitChanges(); if (identity != null) { DataAccess.Login createdLogin = DataAccess.Login.FindLoginByUsernameOrCallsign(db, username); if (createdLogin != null) { status = System.Web.Security.MembershipCreateStatus.Success; var memebershipUser = MembershipUserUtility.CreateMembershipUserFromLogin(createdLogin); if (memebershipUser != null) { SendWelcomeEmail(memebershipUser); } return(memebershipUser); } } } status = System.Web.Security.MembershipCreateStatus.ProviderError; return(null); }
public override System.Web.Security.MembershipUser GetUser(object providerUserKey, bool userIsOnline) { // TODO: (Optional) if userIsOnline is true, then the user's last action timestamp may be updated. // the current db schema does not support this column. return(MembershipUserUtility.FindUserByPredicate(p => p.Id == Convert.ToInt32(providerUserKey))); }
public override System.Web.Security.MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords) { return(MembershipUserUtility.FindUsersByPredicate(p => true == true, pageIndex, pageSize, out totalRecords)); }
public override System.Web.Security.MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) { return(MembershipUserUtility.FindUsersByPredicate(p => SqlMethods.Like(p.Username, usernameToMatch.Trim()), pageIndex, pageSize, out totalRecords)); }