+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / custom field in permissions page

custom field in permissions page

10 posts, 1 answered
  1. LouiseBA
    LouiseBA avatar
    61 posts
    Registered:
    23 Mar 2010
    10 Nov 2010
    Link to this post
    Hello

    I need to add a custom field to the Permissions page (..sitefinity/admin/CmsAdmin/Permissions.aspx)

    so in other words, a new value that is associated with a role, in particular.

    I have looked up custom fields which seem to be ok for news, generic content etc, but cannot find how this can be done on this particular page, and I cannot find a corresponding control template for the permissions module to fiddle with.

    The aspx page is there in the solution for Permissions.aspx, but it uses a permissions control for the roles, that I cannot seem to get to.

    Any help appreciated,

    many thanks, Louise.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    11 Nov 2010
    Link to this post
    Hi LouiseBA,

    Pages does not support custom dynamic fields. You can take a look at these posts



    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. LouiseBA
    LouiseBA avatar
    61 posts
    Registered:
    23 Mar 2010
    11 Nov 2010
    Link to this post
    Thanks Ivan. I actually achieved it by creating a seperate grid on the users page and adding my new field to the roles table manually. Its a bit of a fudge but its working..

    next step however, is to use this value (its a login redirect url which is specific to a role) on the login control.

    I have tried amending the code in the login.ascx control code behind  here..

     public string DestinationPage
        {
            get
            {
          //  return this.Login1.DestinationPageUrl; THIS IS HOW IT IS OUT OF THE BOX
            return GetRoleBasedDestinationUrl() ; THIS IS MY NEW FUNCTION, THE DETAILS OF WHICH I WONT GO INTO. BUT IT GETS THE USERS ROLE AND FINDS THE ROLE SPECIFIC URL..I KNOW THIS WORKS
            }

            set
            {
         
                this.Login1.DestinationPageUrl = value;
            }
        }

    It doesnt use my code. If I put a destination url into the control then it just uses that instead. Its like its not firing my code. In fact if I go into debug mode it doesnt hit the breakpoint in the get method.

    Any ideas? thanks, Louise.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    11 Nov 2010
    Link to this post
    Hello LouiseBA,

    Subscribe for LoggedIn event and there make a Response.Redirect. Another option is overriding OnBubbleEvent(object source, EventArgs e) of the login control and making the redirect from there.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  5. LouiseBA
    LouiseBA avatar
    61 posts
    Registered:
    23 Mar 2010
    11 Nov 2010
    Link to this post
    perfect thank you.
  6. LouiseBA
    LouiseBA avatar
    61 posts
    Registered:
    23 Mar 2010
    11 Nov 2010
    Link to this post
    Hmm ... I can't read the roles as even though this event has fired if I put in the correct username and password, IsAuthenticated = false, so the roles retrieval fails. Why is this so if this event is fired after successful authentication?
  7. LouiseBA
    LouiseBA avatar
    61 posts
    Registered:
    23 Mar 2010
    11 Nov 2010
    Link to this post
    my code

      protected override void OnInit(EventArgs e)
            {
            base.OnInit(e);

            this.Login1.LoggedIn += new EventHandler(Login1_RedirectOverride);
            }

        void Login1_RedirectOverride(object sender, EventArgs e)
            {
    // IF I INSPECT THE USER HERE ISAUTHENTICATED IS STILL FALSE
            Response.Redirect(GetRoleBasedDestinationUrl());

            }
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    11 Nov 2010
    Link to this post
    Hello LouiseBA,

    Try using the code below

    protected void Page_Load(object sender, EventArgs e)
    {
     
       this.Login1.LoggedIn += new EventHandler(Login1_LoggedIn);
           this.Login1.Authenticate += new AuthenticateEventHandler(Login1_Authenticate);
    }
     
    void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
            
            // you can check for the user
            //var checkForUser = Membership.Providers[providerName].GetUser(this.Login1.UserName, false);
            // authenticate the user
       e.Authenticated = UserManager.Default.ValidateUser(this.Login1.UserName, this.Login1.Password);
    }
     
       void Login1_LoggedIn(object sender, EventArgs e)
       {
     
        // force setting the authentication cookie.
        HttpCookie cookie = this.Response.Cookies[FormsAuthentication.FormsCookieName];
        UserManager.Default.SetAuthenticationCookie(cookie);
     
       }


    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. LouiseBA
    LouiseBA avatar
    61 posts
    Registered:
    23 Mar 2010
    12 Nov 2010
    Link to this post
    thank you but i am afraid that e.Authenticated = true if I give the correct credentials but when it falls into LoggedIn the UserManager.GetCurrentUser still returns nothing and HttpContext.Current.User.Identity.IsAuthenticated is still false. Its like it authenticates but doesnt set the user object yet. So I still cant inspect the roles to do what i need to do..

    I would rather use the user objects for this, but if I cant get this working I could always read the user/roles table manually myself with the "authenticated" username. Its fudgy though.
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    12 Nov 2010
    Link to this post
    Hello LouiseBA,

    Here is a reference from MSDN.

    "The LoggedIn event is raised after the authentication provider checks the user's credentials and the authentication cookie is queued to send to the browser in the next response. Use the LoggedIn event to provide additional processing, such as accessing per-user data, after the user is authenticated.

    When a user submits his or her login information, the Login control first raises the LoggingIn event, then the Authenticate event, and finally the LoggedIn event."



    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
10 posts, 1 answered