private bool MatchPassword(User dbUser, string password) { var encryptedPassword = ""; string criptoProperties = dbUser.CriptoProperties; if (String.IsNullOrEmpty(criptoProperties)) { encryptedPassword = AuthUtils.GetSha1HashData(password); } //TODO: read criptoProperties and apply custom logic return(dbUser.Password.Equals(encryptedPassword)); }
public User(string userName, string firstName, string lastName, string siteId, string orgId, string department, string phone, string language, string password) { UserName = userName; FirstName = firstName; LastName = lastName; SiteId = siteId; OrgId = orgId; IsActive = true; Department = department; Phone = phone; Language = language; Password = !string.IsNullOrEmpty(password) ? AuthUtils.GetSha1HashData(password) : null; }
public InMemoryUser Login(string userName, string password, string userTimezoneOffset) { var shaPassword = AuthUtils.GetSha1HashData(password); var md5Password = AuthUtils.GetHashData(password, SHA256.Create()); var dbUser = new SWDBHibernateDAO().FindSingleByQuery <User>(LoginQuery, userName); if (dbUser == null || !MatchPassword(dbUser, password)) { return(null); } return(UserFound(dbUser, userTimezoneOffset)); }
public static User fromJson(JObject jObject) { var user = new User(); user.CustomRoles = new HashedSet <UserCustomRole>(); user.CustomConstraints = new HashedSet <UserCustomConstraint>(); user.Profiles = new HashedSet <UserProfile>(); JToken roles = jObject["customRoles"]; if (roles != null) { foreach (JToken jToken in roles.ToArray()) { user.CustomRoles.Add(jToken.ToObject <UserCustomRole>()); } } JToken customConstraints = jObject["customConstraints"]; if (customConstraints != null) { foreach (JToken jToken in customConstraints.ToArray()) { user.CustomConstraints.Add(jToken.ToObject <UserCustomConstraint>()); } } JToken profiles = jObject["profiles"]; if (profiles != null) { foreach (JToken jToken in profiles.ToArray()) { user.Profiles.Add(UserProfile.FromJson(jToken)); } } JToken personGroups = jObject["personGroups"]; if (personGroups != null) { foreach (JToken jToken in personGroups.ToArray()) { if (user.PersonGroups == null) { user.PersonGroups = new HashedSet <PersonGroupAssociation>(); } user.PersonGroups.Add(jToken.ToObject <PersonGroupAssociation>()); } } //fixme: find a better solution, maybe 2 jsons from client user.UserName = (String)jObject["userName"]; user.FirstName = (String)jObject["firstName"]; user.LastName = (String)jObject["lastName"]; user.OrgId = (String)jObject["orgId"]; user.SiteId = (String)jObject["siteId"]; user.IsActive = (bool)jObject["isActive"]; user.Id = (int?)jObject["id"]; user.Email = (String)jObject["email"]; user.Department = (String)jObject["department"]; user.Phone = (String)jObject["phone"]; user.Language = (String)jObject["language"]; var inputPassword = (String)jObject["password"]; if (inputPassword != null) { user.Password = AuthUtils.GetSha1HashData(inputPassword); } user.MaximoPersonId = (String)jObject["maximopersonid"]; return(user); }