AspectizeUser IAuthentication.Authenticate(string userName, string secret, AuthenticationProtocol protocol, HashHelper.Algorithm algorithm, string chalenge) { IDataManager dm = EntityManager.FromDataBaseService(ServiceName.MyDataService); IEntityManager em = dm as IEntityManager; List <User> users = dm.GetEntities <User>(new QueryCriteria(User.Fields.Email, ComparisonOperator.Equal, userName.ToLower().Trim())); if (users.Count > 0) { User user = users[0]; bool match = PasswordHasher.CheckResponse(user.Password, chalenge, algorithm, secret); if (match && user.Status != EnumUserStatus.Blocked) { Dictionary <string, object> dicoProfiles = new Dictionary <string, object>(); List <string> roles = new List <string>(); roles.Add("Registered"); return(AspectizeUser.GetAuthenticatedUser(user.Id.ToString("N"), null, roles.ToArray(), dicoProfiles)); } } return(AspectizeUser.GetUnAuthenticatedUser()); }
AspectizeUser IAuthentication.Authenticate(string userName, string secret, AuthenticationProtocol protocol, HashHelper.Algorithm algorithm, string challenge) { IDataManager dm = EntityManager.FromDataBaseService(DataBaseService); List <User> users = dm.GetEntities <User>(new QueryCriteria(User.Fields.UserName, ComparisonOperator.Equal, userName.ToLower().Trim())); if (users.Count > 0) { User user = users[0]; bool match = PasswordHasher.CheckResponse(user.Password, challenge, algorithm, secret); if (match) { Dictionary <string, object> dicoProperties = new Dictionary <string, object>(); dicoProperties.Add("UserName", user.UserName); List <string> roles = new List <string>(); roles.Add("Registered"); user.DateLastLogin = DateTime.Now; dm.SaveTransactional(); return(AspectizeUser.GetAuthenticatedUser(user.Id.ToString(), null, roles.ToArray(), dicoProperties)); } } return(AspectizeUser.GetUnAuthenticatedUser()); }