onlyAvailableForRoles option does not work properly

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
1/17/2007 7:31:04 AM
Gravatar
Total Posts 488

onlyAvailableForRoles option does not work properly

I have created my own file instead of mojoProfile.config and added a line to user.config to replace it.

In my file I have 2 profile properties, one with 'onlyAvailableForRoles="Managers"', the other with 'onlyAvailableForRoles="Customers"' (both "Customers" and "Managers" are existing site roles).

1. User in the role "Admins" has both properties.

2. It seems that (on pages /Admin/ManageUsers.aspx, /ProfileView.aspx, etc) properties visibility is based on current logged in user roles, but not on the roles of the user whos profile is being veiwed/edited. That is not correct.
1/17/2007 5:11:55 PM
Gravatar
Total Posts 18439

Re: onlyAvailableForRoles option does not work properly

I will look into improving this soon. I had to get the 2.2.1 release out quickly to fix a significant bug in the forums module.

Thanks,

Joe
1/18/2007 2:53:07 AM
Gravatar
Total Posts 488

Re: onlyAvailableForRoles option does not work properly

Ok, I shall wait for a while with this...
1/18/2007 5:13:02 PM
Gravatar
Total Posts 18439

Re: onlyAvailableForRoles option does not work properly

This is now fixed in svn branches/2.x, you'll need to run the stored proc script to get the latest procs.

Thanks,

Joe
1/19/2007 5:12:50 AM
Gravatar
Total Posts 488

Re: onlyAvailableForRoles option does not work properly

I have updated from SVN and rerun the script 3CreateStoredProcedures.sql - nothing changed.

Properties visibility is still based on the roles of currently logged in user, but not the one whose profile I am looking at.

My testing file (WebProfile.config instead of mojoProfile.config):





<?xml version="1.0"?>
<mojoProfile>
    <properties>
        <!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
               
             PROPERTIES FOR MANAGERS (role 'Managers')
       
             * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        -->

        <add    name="Gender"
                type="System.String"
                allowMarkup="false"
                labelResourceKey="GenderLabel"
                lazyLoad="false"
                requiredForRegistration="false"
                allowAnonymous="false"
                visibleToAnonymous="false"
                visibleToAuthenticated="true"
                visibleToUser="true"
                editableByUser="true"
                regexValidationExpression=""
                validationErrorResourceKey=""
                onlyAvailableForRoles="Managers"
                defaultValue=""
                includeHelpLink="true"
                >
            <OptionList>
                <Option value="" TextResourceKey="GenderUnselectedLabel"></Option>
                <Option value="M" TextResourceKey="GenderMaleLabel"></Option>
                <Option value="F" TextResourceKey="GenderFemaleLabel"></Option>
            </OptionList>
        </add>
               
        <!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
               
             END OF PROPERTIES FOR MANAGERS (role 'Managers')
       
             * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        -->





        <!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
               
             PROPERTIES FOR CUSTOMERS (role 'Customers')
       
             * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        -->

        <add    name="WebSiteUrl"
                type="System.String"
                allowMarkup="false"
                labelResourceKey="WebSiteUrlLabel"
                lazyLoad="false"
                requiredForRegistration="false"
                visibleToAnonymous="true"
                visibleToAuthenticated="true"
                visibleToUser="true"
                editableByUser="true"
                regexValidationExpression="(((http(s?))\://){1}\S+)"
                regexValidationErrorResourceKey="WebSiteUrlRegexWarning"
                maxLength="100"
                columns="45"
                onlyAvailableForRoles="Customers"
                includeHelpLink="false"
                        />

        <!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
               
             END OF PROPERTIES FOR ALL CUSTOMERS (role 'Customers')
       
             * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        -->
 
    </properties>
</mojoProfile>




I have 2 users on my site (except admin) - customer (roles: Authenticated Users; Customers) and manager (roles: Authenticated Users; Managers).
When I log in as customer everyone has only
WebSiteUrl. When I log in as manager everyone has only Gender.
When I log in as admin everyone has both properties.
1/19/2007 7:38:08 AM
Gravatar
Total Posts 18439

Re: onlyAvailableForRoles option does not work properly

Did you re-compile? It works correctly when I test it here.

In the mojoProfile.config file there is a commented out DateOfBirth property configured for Content Administrators
When I add that property (by uncommenting it) and login as Admin and look at user profiles on the ManageUsers.aspx page, I only see DateOfBirth on the profiles of users in the Content Administrators role.

Joe
1/19/2007 8:42:19 AM
Gravatar
Total Posts 488

Re: onlyAvailableForRoles option does not work properly

Once more I updated, rebuilt the solution, runned the script 3CreateStoredProcedures.sql and iisreset - the same result.

Just forgot to mention, I use MSSQL data.
1/19/2007 9:04:50 AM
Gravatar
Total Posts 18439

Re: onlyAvailableForRoles option does not work properly

Are you sure its using your custom file and not mojoProfile.config?
Can you step through the code in ManageUsers.aspx.cs and see if it sees the role requirement for those properties.
Also make sure the role names specified correspond to RoleName column in db not DisplayName

Joe
1/19/2007 9:45:12 AM
Gravatar
Total Posts 488

Re: onlyAvailableForRoles option does not work properly

I founded out that on /Admin/ManageUsers.aspx it works for en-US browser locale and does not for ru-RU.

I just created the roles and did not rename them, so role names and captions should be the same.
1/19/2007 9:59:28 AM
Gravatar
Total Posts 18439

Re: onlyAvailableForRoles option does not work properly

Ok, I just committed a change to svn branches/joesandbox2 that may fix it, can you try it?

Thanks,

Joe
1/19/2007 10:14:19 AM
Gravatar
Total Posts 488

Re: onlyAvailableForRoles option does not work properly

Now it works on /Admin/ManageUsers.aspx for both en-US and ru-RU.

But for both russian and english locales it still:
1. Shows previously stored WebSiteUrl value for "Admins" role on /MemberList.aspx (I have this property only for "Customers" role)
2. Shows incorrect properties set on /ProfileView.aspx
3. Shows incorrect properties set on /ProfileView.aspx
1/19/2007 10:38:19 AM
Gravatar
Total Posts 18439

Re: onlyAvailableForRoles option does not work properly


1. then clear that property from the admin user in the db, I'm not going to code for that, having WebSiteUrl based on roles is a highly unusual use case to begin with

2 and 3 are the same?, please clarify what you mean incorrect properties. I implemented it so that if you are in the role you see the property, except admins who see all as nothing is hidden form admins and IsInRole always returns true for Admins.

Joe
1/19/2007 10:43:11 AM
Gravatar
Total Posts 18439

Re: onlyAvailableForRoles option does not work properly

ok, I see what you mean, if I'm in the role I see the property for all users on ProfileView, I will fix that.

Joe
1/19/2007 10:48:33 AM
Gravatar
Total Posts 488

Re: onlyAvailableForRoles option does not work properly

1. I agree, I just noticed it because my test property was WebSiteUrl.

2 and 3. - yes, they are the same, it's a writing mistake.
Ok, waiting for the fix.

I think that having all roles for admins is not a good solution.
For example I have some mandatory fields (like zip, passport no, etc) for customers and do not want to have them mandatory for admins.
1/19/2007 10:58:56 AM
Gravatar
Total Posts 18439

Re: onlyAvailableForRoles option does not work properly

They properties for Customers will not show up on ManageUsers.aspx when viewing the Admin user's profile unless he (the Admin) is also in customer role. However the admins will see that property when viewing the profiles of customers, no properties are hidden from Admins. Admins do not inherit all properties.

To be more clear, WebUser.IsInRoles always returns true for Admins and is what is used to check the roles of the httpcontext user, but siteUser.IsInRoles only returns true if the user is in the role and should be used to check the roles of a user other than the httpcontext user

ProfileView is now fixed in svn, it only shows the property if the httpcontextuser and the user whose profile is being viewed are both in the role, that is WebUser.IsInRoles and siteUser.IsInRoles both must be true if roles are specified for the property

Joe
1/19/2007 11:22:33 AM
Gravatar
Total Posts 488

Re: onlyAvailableForRoles option does not work properly

I have updated and recompiled.

On my testing environment admin is only in roles "Admins" and "Authenticated Users".
I login as admin and
    - go to /ProfileView.aspx - everything is correct (WebSiteUrl for customer, Gender for manager, none for admin)
    - go to /Admin/ManageUsers.aspx - everything is correct (WebSiteUrl for customer, Gender for manager, none for admin)
    - go to /Secure/UserProfile.aspx - I can see both Gender and WebSiteUrl properties there (for both en-US and ru-RU)
1/19/2007 11:36:21 AM
Gravatar
Total Posts 18439

Re: onlyAvailableForRoles option does not work properly

oh, you are right, should be using siteUser.IsInRoles not WebUser.IsInRoles on the UserProfile page in order to handle admin profile correctly.
Fixed in svn.

Joe
1/19/2007 11:59:35 AM
Gravatar
Total Posts 488

Re: onlyAvailableForRoles option does not work properly

Still having problems.

1. Login as customer, go to /ProfileView.aspx of customer - ok, go to /ProfileView.aspx of manager - no properties are displayed.
2. Login as manager, go to /ProfileView.aspx of manager - ok, go to /ProfileView.aspx of customer - no properties are displayed.
3. Logout, set AllowAnonymousUsersToViewMemberList option in web.config to "true", go to /ProfileView.aspx - see WebSiteUrl property for all users and nothing more (except a message that some properties were hidden as I am not logged in).

P.S. UserProfile page works properly now.
1/19/2007 12:34:14 PM
Gravatar
Total Posts 18439

Re: onlyAvailableForRoles option does not work properly

Maybe I didn't understand your original request for the role based property feature. I did not think users should be able to see properties for roles which they are not in regardless of whether they are logged in or not. If a property is only for managers my thinking was others should not be able to see that property, only other managers (or Admins) will see that.

I can change this but thats what I thought you wanted. It sounds (now) like you only want the role to determine only who has the property but visibility of the property is determined only on IsVisibleToAnonymous and IsVisibleToAuthenticated?

Joe
1/19/2007 1:27:03 PM
Gravatar
Total Posts 488

Re: onlyAvailableForRoles option does not work properly

I want the property onlyAvailableForRoles to work as follows: the specified profile property just exists for users in one of the specified roles, and do not exist in any others.
So, it is showed in profile of users of the specified roles and is not showed in any other ones'.

Property visibility in this case is determined by onlyAvailableForRoles, IsVisibleToAnonymous and IsVisibleToAuthenticated - if it is not available for some user (due to the role set) it is not displayed anyway.

For your understanding of the feature there should be some property option like onlyVisibleToRoles. It will also be nice to have it (may be even instead of IsVisibleToAuthenticated), but it is not the one I originally requested.

P.S. May be, "onlyExistsForRoles" "onlyHandledForRoles" would be a better name for this option.
1/19/2007 2:32:51 PM
Gravatar
Total Posts 18439

Re: onlyAvailableForRoles option does not work properly

I like onlyAvailableForRoles and onlyVisibleForRoles better than onlyExistsForRoles and onlyHandledForRoles

I've implemented this in svn.

I'll update the documentation as soon as I get a chance.

Thanks,

Joe
1/22/2007 6:43:47 AM
Gravatar
Total Posts 488

Re: onlyAvailableForRoles option does not work properly

I did not use onlyVisibleForRoles yet, but I have tested onlyAvailableForRoles once more.
Now it works except one issue.

I have a testing profile config as I showed above. I set visibleToAnonymous="true" for both of them, but still see "Some information is not shown because you are not logged into this site." message when viewing user profiles without login (all the profile properties are available as they should be).
1/22/2007 1:33:33 PM
Gravatar
Total Posts 18439

Re: onlyAvailableForRoles option does not work properly

If there are any properties marked as visibleToAnonymous=false and visibleToAuthenticated = true, the message will be displayed. I did modify it today so that if the property has roles specified in the onlyVisibleToRoles setting then I don't count that in deciding whether to display the message because I can't assume that if the user logs in he will be in a role that allows viewing the property.

There are several properties in mojoProfile.config that are marked as only visible to authenticated users, therefore anonymous users see this message. This is designed to encourage people to register and login.

Joe
1/23/2007 6:38:10 AM
Gravatar
Total Posts 488

Re: onlyAvailableForRoles option does not work properly

Finally it all works, thanks.
You must sign in to post in the forums. This thread is closed to new posts.