示例#1
0
        public void IsInRole_UserWithRoleMemberIsNotAdmin_ReturnsTrue()
        {
            User user = new User {Role = Role.Member};

            var hasAdminMember = user.IsInRole(Role.Admin.ToString());

            Assert.IsFalse(hasAdminMember);
        }
示例#2
0
        public void IsInRole_UserWithRoleEditorHasRoleMember_ReturnsTrue()
        {
            User user = new User {Role = Role.Editor};

            var hasRoleMember = user.IsInRole(Role.Member.ToString());

            Assert.IsTrue(hasRoleMember);
        }
示例#3
0
        public void IsInRole_HasDefaultRole_ReturnsTrue()
        {
            User user = new User();

            var isMember = user.IsInRole(Role.Member.ToString());

            Assert.IsTrue(isMember);
        }
示例#4
0
        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);
        }
示例#5
0
 /// <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;
 }