public string CreateHash(UserProfilePart profilePart, ApplicationRecord applicationRecord) { UserProfilePartRecord profileRecord = _userprofileRepository.Get(profilePart.Id); if (profileRecord == null) { return(null); } // first delete all hashes for this user and application CleanupHashes(profilePart, applicationRecord); var utcNow = _clock.UtcNow; LoginsRecord r = new LoginsRecord(); r.Hash = createHash(profileRecord.Id, applicationRecord.Id, DelayToValidate); r.UserProfilePartRecord = profileRecord; r.ApplicationRecord = applicationRecord; r.UpdatedUtc = utcNow; _loginsRepository.Create(r); return(r.Hash); }
public IEnumerable <UserRoleRecord> GetUserRoles(UserProfilePart profilePart, ApplicationRecord appRecord) { UserProfilePartRecord profileRecord = _userprofileRepository.Get(profilePart.Id); if (profileRecord == null) { return(null); } var record = profileRecord.Applications.FirstOrDefault(x => x.ApplicationRecord.Name == appRecord.Name); if (record == null) { return(new List <UserRoleRecord>()); } var Roles = new List <UserRoleRecord>(); foreach (UserUserRoleRecord con in profileRecord.Roles) { if (con.UserRoleRecord.ApplicationRecord.Id == appRecord.Id) { Roles.Add(con.UserRoleRecord); } } return(Roles); }
public string GetHash(UserProfilePart profilePart, ApplicationRecord applicationRecord) { UserProfilePartRecord profileRecord = _userprofileRepository.Get(profilePart.Id); if (profileRecord == null) { return(null); } try { var logins = from login in _loginsRepository.Table where login.ApplicationRecord.Id == applicationRecord.Id && login.UserProfilePartRecord.Id == profilePart.Id select login; //foreach (LoginsRecord login in logins) //{ // _loginsRepository.Delete(login); //} var first = logins.FirstOrDefault(); if (first != null) { return(first.Hash); } } catch { return(null); } return(null); }
public bool CreateUserForApplicationRecord(UserProfilePart profilePart, ApplicationRecord appRecord) { UserProfilePartRecord profileRecord = _userprofileRepository.Get(profilePart.Id); if (profileRecord == null) { return(false); } var utcNow = _clock.UtcNow; var record = profileRecord.Applications.FirstOrDefault(x => x.ApplicationRecord.Name == appRecord.Name); if (record == null) { profileRecord.Applications.Add(new UserApplicationRecord { UserProfilePartRecord = profileRecord, ApplicationRecord = appRecord, RegistrationStart = utcNow }); TriggerSignal(); } if (profileRecord.Roles == null || profileRecord.Roles.Count == 0) { UserRoleRecord defaultrole = _applicationsService.GetDefaultRole(appRecord); profileRecord.Roles.Add(new UserUserRoleRecord { UserProfilePartRecord = profileRecord, UserRoleRecord = defaultrole }); } return(true); }