Exemple #1
0
        public override bool ValidateUser(Guid userId, string password)
        {
            MembershipUser user = CobaltWebApi.GetUserById(userId);

            if (user != null && !string.IsNullOrEmpty(user.UserName))
            {
                return(this.ValidateUser(user.UserName, password));
            }
            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Gets information from the data source for a user based on the unique identifier for the membership user. Provides an option to update the last-activity date/time stamp for the user.
        /// </summary>
        /// <param name="providerUserKey">The unique identifier for the membership user to get information for.</param>
        /// <param name="userIsOnline">true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user.</param>
        /// <returns>
        /// A <see cref="T:System.Web.Security.MembershipUser"></see> object populated with the specified user's information from the data source.
        /// </returns>
        public override System.Web.Security.MembershipUser GetUser(object providerUserKey, bool userIsOnline)
        {
            Guid           id   = (Guid)providerUserKey;
            MembershipUser user = CobaltWebApi.GetUserById(id);

            if (user != null)
            {
                return(this.CreateMembershipUser(user));
            }
            return(null);
        }
Exemple #3
0
        public override IQueryable <Role> GetRolesForUser(Guid userId)
        {
            MembershipUser user  = CobaltWebApi.GetUserById(userId);
            List <Role>    roles = new List <Role>();

            roles.AddRange(user.UserRoles.Select(r => new Role()
            {
                Id = r.Id, ApplicationName = base.ApplicationName, Name = r.Name
            }));
            roles.AddRange(user.UserGroups.Select(r => new Role()
            {
                Id = r.Id, ApplicationName = base.ApplicationName, Name = r.Name
            }));
            return(roles.AsQueryable <Role>());
        }
Exemple #4
0
        public override User GetUser(Guid id)
        {
            MembershipUser user = CobaltWebApi.GetUserById(id);

            if (user != null)
            {
                User newUser = new User()
                {
                    Id = user.Id, ApplicationName = base.ApplicationName, IsApproved = true
                };
                newUser.SetUserName(user.UserName);
                return(newUser);
            }
            return(null);
        }
Exemple #5
0
        public override bool IsUserInRole(Guid userId, string roleName)
        {
            MembershipUser user = CobaltWebApi.GetUserById(userId);

            return(user.UserRoles.Any(r => r.Name == roleName) || user.UserGroups.Any(r => r.Name == roleName));
        }
Exemple #6
0
        public override bool IsUserInRole(Guid userId, Guid roleId)
        {
            MembershipUser user = CobaltWebApi.GetUserById(userId);

            return(user.UserRoles.Any(r => r.Id == roleId) || user.UserGroups.Any(r => r.Id == roleId));
        }