public void IsInRole_UserWithRoleMemberIsNotAdmin_ReturnsTrue() { User user = new User {Role = Role.Member}; var hasAdminMember = user.IsInRole(Role.Admin.ToString()); Assert.IsFalse(hasAdminMember); }
public void IsInRole_UserWithRoleEditorHasRoleMember_ReturnsTrue() { User user = new User {Role = Role.Editor}; var hasRoleMember = user.IsInRole(Role.Member.ToString()); Assert.IsTrue(hasRoleMember); }
public void IsInRole_HasDefaultRole_ReturnsTrue() { User user = new User(); var isMember = user.IsInRole(Role.Member.ToString()); Assert.IsTrue(isMember); }
public bool CanEdit(User user) { if (user == null) return false; if (user.Role == Role.Member) return Settings.Current.Permissions.AllowMembersToCreateSnippets && Author.UserId == user.UserId; return user.IsInRole(Role.Editor); }
/// <summary> /// Checks if logged in user can create snippets. /// </summary> /// <param name="user"></param> /// <returns></returns> public bool CanCreate(User user) { if (user == null) return false; return user.IsInRole(Role.Editor) || Settings.Current.Permissions.AllowMembersToCreateSnippets; }