Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • trfletch 595 posts 571 karma points
    Nov 11, 2009 @ 14:08
    trfletch
    0

    Member opens specific page when loggin in

    Hi,

    I have installed the member controls in my Umbraco V4 website and I have pages stuctured as follows:

    Client login page (this page has a login box)
        - Client 1 page
        - Client 2 page

    I then have members called Client 1 and Client 2. Basically I want to know if it is possible that when Client 1 logs in on the Client login page they are taken to Client 1 page and when Client 2 logs in they are taken to Client 2 page. Is this something that can be done fairly simply?

     

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Nov 11, 2009 @ 14:16
    Dirk De Grave
    0

    I haven't used the member controls as I tend to use the plain asp.net login controls, which do have an event that's fired after successful login. If you'd use this technique, you could easily redirect the logged in member to its client page. you'll also need to establish a link between a member and its client page (most probably the node id of the page)

    And which member controls package are you using?

     

    Hope this helps.

    Regards,

    /Dirk

  • trfletch 595 posts 571 karma points
    Nov 11, 2009 @ 15:02
    trfletch
    0

    Hi Dirk,

    Just using the ones that I downloaded from the package repository in Umbraco developer section. So how do I use the asp.net ones and create a link between the member and the page? Would this link be something I would have to setup each time for a new client? I was hoping that the end user could just create a new client page and member login in Umbraco without having to do anything too difficult to associate them with each other.

  • trfletch 595 posts 571 karma points
    Nov 11, 2009 @ 15:05
    trfletch
    0

    Would it be better or maybe easier to have some sort of XSLT list on the login page that lists the child nodes of that page but only shows the ones that logged in member has access to? So when Client 1 logs in they would see something like this:

     

    Click here to view Client 1 page (this would be a link to their page)

  • Chris Koiak 700 posts 2626 karma points
    Nov 11, 2009 @ 15:57
    Chris Koiak
    0

    Rather than outputing a link, you could loop through the child pages.. find the first one that the user has access to and 301/302 redirect to this page.

    You could accomplish the 301 redirect as described at http://our.umbraco.org/forum/using/ui-questions/5255-301-redirect-options

     

  • trfletch 595 posts 571 karma points
    Nov 11, 2009 @ 16:51
    trfletch
    0

    Where could I find the XSLT code that I would need to loop through the child pages and find one that the user has access to?

  • Chris Koiak 700 posts 2626 karma points
    Nov 11, 2009 @ 17:06
    Chris Koiak
    0

    Something like...

     

    <ul>
    <xsl:for-each
    select="$currentPage/child::node [string(data [@alias='umbracoNaviHide']) != '1']">
     
    <xsl:if test="umbraco.library:HasAccess(@id, @path) = true()">
       
    <li>
           
    <a href="{umbraco.library:NiceUrl(@id)}">            
               
    <xsl:value-of select="@nodeName"/>
           
    </a>
       
    </li>
     
    </xsl:if>
    </xsl:for-each>
    </ul>

    The above will list the pages that the user has access to. You could perform a redirect rather than outputting the <li>

  • trfletch 595 posts 571 karma points
    Nov 11, 2009 @ 17:48
    trfletch
    0

    Thanks Chris, that is exactly what I need although I still don't quite understand how I get the redirect to work, I have read the thread you posted above but I'm not too sure how I incorporate that into my XSLT to redirect instead of listing the pages. I know that I have to put something in between the xsl:if statements but not sure exactly what.

  • Casey Neehouse 1339 posts 483 karma points MVP 2x admin
    Nov 12, 2009 @ 05:29
    Casey Neehouse
    0

    Below is an example using the .NET login controls:


    <script runat="server">
            protected void Login1_LoggedIn(object sender, EventArgs e)
            {
    // the context is not set yet?, so must lookup the user based on login username
    string name = umbraco.cms.businesslogic.member.Member.GetMemberFromLoginName(((Login)sender).UserName).Text
                if (name=="client")
                {
      Response.Redirect(umbraco.library.NiceUrl(1897), true);
                }
            }
    </script>
    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">

        <asp:LoginView ID="LoginView1" runat="server"></asp:LoginView>
    </asp:Content>
  • trfletch 595 posts 571 karma points
    Nov 16, 2009 @ 17:23
    trfletch
    0

    Thanks Casey, although I am still unsure how I make the method you have described work with the member controls I am using, I have tried the following code but this does not work:

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
     exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <xsl:for-each select="$currentPage/child::node [string(data [@alias='umbracoNaviHide']) != '1']">
      <xsl:if test="umbraco.library:HasAccess(@id, @path) = true()">
    <script runat="server">
        Private Sub Page_Load(sender As Object, e As EventArgs)
            ' Check whether the browser remains
            ' connected to the server.
            If (Response.IsClientConnected) Then
                ' If still connected, redirect
                ' to another page.      
         
                Response.Redirect("umbraco.library:NiceUrl(@id)", false)
            Else
                ' If the browser is not connected
                ' stop all response processing.
                Response.End()
            End If
        End Sub
    </script>
       
     </xsl:if>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>
  • Chris Koiak 700 posts 2626 karma points
    Nov 17, 2009 @ 14:47
    Chris Koiak
    0

    Try changing your xslt as follows

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
     
    version="1.0"
     
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:redir="urn:redir:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
     
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <msxsl:script language="C#" implements-prefix="redir">
    <msxml:assembly name="System.Web" />
    <msxml:using namespace="System.Web" />
    <![CDATA[
    public String Redirect(String url){
    System.Web.HttpContext.Current.Response.Status = "301 Moved Permanently";
    System.Web.HttpContext.Current.Response.AddHeader("Location", url.ToString());
    return "";
    }
    ]]>
    </msxsl:script>

    <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <xsl:for-each select="$currentPage/child::node [string(data [@alias='umbracoNaviHide']) != '1']">
     
    <xsl:if test="umbraco.library:HasAccess(@id, @path) = true()">
    <xsl:value-of select="redir:Redirect(umbraco.library:NiceUrl(@id))" />
     </xsl:if>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

    However at this point i'd probably just write a C# usercontrol that sits on the page and performs the check/redirect.

  • trfletch 595 posts 571 karma points
    Nov 17, 2009 @ 18:33
    trfletch
    0

    Hi Chris,

    Thanks for your response, I tried using the XSLT you suggested but I received the following error when trying to save the file, I assume I am missing a line that declares the namespace?

    System.Xml.XmlException: 'msxsl' is an undeclared namespace. Line 11, position 4. 
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies