public void Test_UserSession() { var session = new UserSession( new List<UserRoleRelation>() ); Assert.IsNotNull(session.Privileges, "Privileges"); }
/// <summary> /// Creates the user session for the user with the specified email address. /// </summary> /// <param name="address">The address.</param> /// <returns></returns> private UserSession Create(string address) { if (string.IsNullOrEmpty(address)) { return Guest(); } var user = this.UserRepository.GetBy(new UserEmailAddressSpecification(address)); if (user == null) { return Guest(); } // user privileges var privileges = this.UserRoleService.GetPrivileges(new UserRoleRelationUserSpecification(user.Id)); // user session var session = new UserSession(privileges) { Id = user.Id, Name = user.Name, Slug = user.Slug, TimeZone = user.Preference.TimeZone.Title, Dst = user.Preference.Dst, TimeFormat = user.Preference.TimeFormat }; user.HostAddress = this.UserHostService.GetAddress(); user.LastVisit = DateTime.Now; this.UserRepository.Update(user); return session; }