Copied to clipboard

Flag this post as spam?

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


  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 17, 2011 @ 16:03
    Bjarne Fyrstenborg
    0

    Weird login/logout problem

    Hi..

    I have created a page "Mine tilmeldte events", where I have set protection to that page.

    http://ak-security.dk/aktuelt/nyheder.aspx

    So that page shouldn't be visible in the navigation, when you are not logged in.
    The user can login at the bottom of page: http://ak-security.dk/aktuelt/nyheder.aspx ,  but after I log out, it doesn't seem to log out correctly, because when I click at the menu item "Akuelt" a couple of times I shows that the user still is logged in?

    Bjarne

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 17, 2011 @ 16:30
    Tom Fulton
    0

    Hi Bjarne,

    This behavior is probably related to this bug where users don't  get signed "all the way" out.  I believe it's been fixed for 4.7.1.  In the comments of that link there is a workaround where you can add some extra code to your Logout button to completely logoff the member.  I think you'll need to implement your logout in a C# usercontrol though to add this code, if you are not already.

    -Tom

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 17, 2011 @ 17:35
    Bjarne Fyrstenborg
    0

    It seems that this http://umbraco.codeplex.com/SourceControl/changeset/changes/cd6cf2e856d9  should fix it.. but where shall the code be placed?

    Bjarne

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 17, 2011 @ 17:40
    Tom Fulton
    0

    I think you'd need to download the source from that (or a later changeset), compile it, and copy over bin, umbraco, umbraco_client.  Or you could try nightly.umbraco.org and download the latest compiled 4.7.1 and do the same.  There could of course be other ramifications of doing this since 4.7.1 isn't finalized yet, but it will probably work.  Of course make sure to backup your entire site first :)

    Or use the workaround described in the comments of the workitem, works for me :)

    -Tom

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 17, 2011 @ 18:01
    Bjarne Fyrstenborg
    0

    Thanks..

    Do you have an example of a usecontrol with the workaround and the logout button?

    Bjarne

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 18, 2011 @ 19:00
    Tom Fulton
    1

    uLogin is a good start, it's a usercontrol that handles login/logout.  You can add the extra code to the DoLogout() method.

    -Tom

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 18, 2011 @ 19:45
    Bjarne Fyrstenborg
    0

    Okay..

    But it don't seem to that I have access to the codebehind?

    Somehow it has just created 15 copies of my eventArea.xslt file after I installed the package... weird.

    Bjarne

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 18, 2011 @ 19:49
    Tom Fulton
    1

    You'll want to download the source from the Source Code tab so you can make the change, then compile and copy over the DLL.

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 18, 2011 @ 20:05
    Bjarne Fyrstenborg
    0

    Okay..

    So I need to add this code inside the DoLogout() method?

    public static bool IsLoggedOn()
                {
                if (HttpContext.Current.User == null)
                {
                return false;
                }
                if (!HttpContext.Current.User.Identity.IsAuthenticated)
                {
                int id = CurrentMemberId();
                if (id > 0)
                {
                FormsAuthentication.SetAuthCookie(new Member(id).LoginName, true);
                return true;
                }
                }
                return HttpContext.Current.User.Identity.IsAuthenticated;
                }
    
                int memberID = Member.CurrentMemberId();
                Member.ClearMemberFromClient(memberID);
    
                FormsAuthentication.SignOut();
                Session.Abandon();

    It seems I need to do more as I'm getting some red marks.

    Bjarne

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 18, 2011 @ 21:04
    Tom Fulton
    1

    Try replacing the DoLogout method with this:

            protected void DoLogout()
            {
                int memberID = umbraco.cms.businesslogic.member.Member.CurrentMemberId();
                umbraco.cms.businesslogic.member.Member.ClearMemberFromClient(memberID);

                System.Web.Security.FormsAuthentication.SignOut();

                Session.Abandon();

                Response.Redirect(Request.RawUrl, true);
            }

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 18, 2011 @ 21:18
    Bjarne Fyrstenborg
    0

    I'm sure I'm doing it right, cause when I build the project without any changes and replace the usercontrol and dll-file a get a assembly error: http://ak-security.dk/forside.aspx

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 18, 2011 @ 21:21
    Tom Fulton
    1

    Hmm.  These are the steps you should do:

    - Compile your changes
    - Copy the /bin/AmplusCorp.uLogin.dll file from your compiled project to /bin/ on your website
    - Copy the uLogin.ascx file from your project to /usercontrols/AmplusCorp/
    - No need to copy the ascx.cs file

    -Tom

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 18, 2011 @ 21:28
    Bjarne Fyrstenborg
    0

    Okay.. 

    I use Visual Web Developer 2010 Express, so I choose Debug > Build uLogin (project name) ...
    the dll is just called uLogin.dll so a rename it to AmplusCorp.uLogin.dll and replace it .. and the same with the usercontrols..

    but it shows the error even when no changes are made?

    Bjarne

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 18, 2011 @ 21:32
    Tom Fulton
    1

    Ah ok, it looks like the DLL in the original package file was named AmplusCorp.uLogin.dll, but in the source version it's just uLogin.dll

    So try deleting the original AmplusCorp.uLogin from your website's /bin/ folder, make sure you copied the files above over, and it should (hopefully) start working.

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 18, 2011 @ 21:48
    Bjarne Fyrstenborg
    0

    That was better.. it doens't like if you rename the file afterwards. Or perhaps the dll file and usercontrols should have same name..

    It works with when I don't rename the files and upload the ulogin.dll and ulogin.ascx files.
    And it seems to log out correctly, when I use the ulogin log out button on same page as the login control and then it also hide one of the menu item on left here http://ak-security.dk/aktuelt/nyheder.aspx as it should be.

    But I guess I need to do something more with the log out button at bottom of the page: http://ak-security.dk/forside.aspx

    It's just a LoginStatus control, which show "Medarbejder login" when you not are logged in and "Log ud" when you are logged in.

    The uLogin seems just to be a <asp:net Login /> control..?

    Bjarne 

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 18, 2011 @ 21:56
    Tom Fulton
    1

    Glad it's working!

    uLogin isn't a asp:Login control, it's a usercontrol that does all the "wiring up" of the login process manually.

    I guess you are still having the bug if you use the logout button at the bottom?  You'll need the code you added to DoLogout to execute to properly log out until the bug is fixed in Umbraco.  So one thing you could do is replace your Logout button/control with an XSLT macro - you can use umbraco.library:IsLoggedOn() to show different output for each case. 

    The Logout button could link to your page where the uLogin macro is and the user can click Logout from there.  If you wanted to save the user a click, you could even have the link goto your uLogin page with something like ?logout=1 at the end, then check for that in the uLogin code and call DoLogout() manually.

    -Tom

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 18, 2011 @ 22:06
    Bjarne Fyrstenborg
    0

    Okay..
    well the login control I used before was splittet up or what it's called:

    <asp:Login id="Login1" runat="server">
    <LayoutTemplate>
    <asp:Label ID="Usernamelbl" runat="server" Text="Brugernavn" Width="120px" /><asp:TextBox ID="UserName" runat="server" CssClass="textbox"></asp:TextBox><br class="clearBoth" />
    <asp:Label ID="Passwordlbl" runat="server" Text="Adgangskode" Width="120px" /><asp:TextBox ID="Password" runat="server" TextMode="Password" CssClass="textbox"></asp:TextBox><br class="clearBoth" />
    <asp:LinkButton ID="submitLoginBtn" CommandName="Login" runat="server" CssClass="small_button floatRight loginBtn"><span>Login</span></asp:LinkButton>
    <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
    </LayoutTemplate>
    </asp:Login>

    Yes, the uLogin log out button works... but not the one I use at the bottom..
    But perhaps I can use DoLogout to the LoginStatus if I create it as a usercontrol..

    Bjarne

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 19, 2011 @ 00:14
    Bjarne Fyrstenborg
    0

    Okay.. I finally think I got it working, as it normal should works :)

    I have used the uLogin control for login control, with a little bit modification... and the I have a LoginStatus control at the bottom of page. I then use the DoLogOut for that control also:

     

    using umbraco;
    using umbraco.cms.businesslogic;
    using umbraco.cms.businesslogic.member;
    ...
    protected void Page_Load(object sender, EventArgs e) { } protected void DoLogout() { int memberID = umbraco.cms.businesslogic.member.Member.CurrentMemberId(); umbraco.cms.businesslogic.member.Member.ClearMemberFromClient(memberID); System.Web.Security.FormsAuthentication.SignOut(); Session.Abandon(); Response.Redirect(Request.RawUrl, true); } protected void loginstatus_LoggingOut(object sender, LoginCancelEventArgs e) { DoLogout(); }

     

    Thanks for all your help Tom... I really appriciate :)

    Bjarne

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 19, 2011 @ 12:05
    Bjarne Fyrstenborg
    0

    Is it possible to activate the enter-button to login?
    Like it is here on our.umbraco.org..

    Right now I have to click on the login button with the mouse.

    Bjarne

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 19, 2011 @ 13:56
    Tom Fulton
    1

    If you have your login button as a normal asp:Button it should work, it looks like you're using a LinkButton right now.  Or if you want to keep it that way you could use some javascript.

    -Tom

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 19, 2011 @ 14:08
    Bjarne Fyrstenborg
    0

    Yes, I have changed the button to a LinkButton and placed a label inside (which gives a span as output) around the text..
    The way I styled the button, the same way as the tabs with a span tag inside an anchor tag, so nomatter the text-length, it keep the same padding arround the text.

    Okay.. I will have a look at it.. I think the asp:Button generates some javascript too at runtime.? where the LinkButton is like a normal link, but which allow to use some code in the .cs file.

    Bjarne

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 19, 2011 @ 14:12
    Tom Fulton
    0

    Gotcha - I would try some of the links above.  If a normal "form submit" from javascript doesn't work you can always use javascript to "click" the LinkButton on enter.

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 19, 2011 @ 14:17
    Bjarne Fyrstenborg
    0

    I will try that.. once again thank for all your help Tom :)

    Nice to have solved the problem with login forms in 4.7.0 version of Umbraco.. hope it will be fixed soon.. anyway uLogin is nice to know, when working with multilingual sites and ready to use.. and easy to add modification if it's neeeded.

    Bjarne

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 19, 2011 @ 20:24
    Bjarne Fyrstenborg
    0

    Do you know how the rememberMeSet is used?

    I don't think it does anything right now..?

    bool _rememberMeSet = false;
    ...
    public bool rememberMeSet { set { _rememberMeSet = value; } }

    I think it should be used to hide the "rember me" function..

    Before it was just a bool, so I changed it to a public bool, so it can be used as parameter in Umbraco.
    I think there need to be done some more to hide this:

    <p id="rememberMe" class="rememberMe">
    <asp:CheckBox ID="rememberMeCheckBox" CssClass="rememberMeCheckBox" runat="server" ClientIDMode="Static" TextAlign="Left" />
    </p>

    Perhaps it is necessary to put that part inside a asp:panel to hide the paragraph too..?

    Bjarne

  • Bjarne Fyrstenborg 1285 posts 4039 karma points MVP 8x c-trib
    Aug 19, 2011 @ 22:05
    Bjarne Fyrstenborg
    0

    I guess the LinkButton doesn't have the submit on enter as default.. but it's earsier to style as it just gives an normal anchor tag as output... and doesn't have the "down" effect as the asp:button has in IE ..

    But as you said before, I can be fixed with some javascript and this worked for me: http://weblogs.asp.net/rternier/archive/2007/10/25/a-linkbutton-defaultbutton-updatepanel-and-firefox.aspx

    Bjarne

  • Ansar 181 posts 291 karma points
    Sep 05, 2011 @ 21:38
    Ansar
    1

    To do logout, I created a Template with following inline Razor... and call this template from any page when user click on the Logout link..

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    <umbraco:Macro  runat="server" language="cshtml">
    @using umbraco.cms.businesslogic.member
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{
      Member m = Member.GetCurrentMember();
      if(m != null){
        Member.RemoveMemberFromCache(m);
        Member.ClearMemberFromClient(m);
      }
      System.Web.Security.FormsAuthentication.SignOut();
      System.Web.Security.Roles.DeleteCookie();
      Session.Clear();
      var rootNode = Model.AncestorOrSelf(1);
      Response.Redirect("/" + rootNode.Name); 
    }
    </umbraco:Macro>
    </asp:Content>

  • Chris Davis 56 posts 74 karma points
    Sep 23, 2011 @ 23:34
    Chris Davis
    0

    Anz,

    How do you call a template from any page when a user clicks on the logout link?

    Thanks.

  • Ansar 181 posts 291 karma points
    Sep 28, 2011 @ 10:40
    Ansar
    0

    Just add ?alttemplate=TEMPLATE NAME at the end of any url

    To use this for Logout button, simply create a Link as follows

    <a href="?alttemplate=logout">Logout</a>

  • Ansar 181 posts 291 karma points
    Sep 28, 2011 @ 10:41
    Ansar
    0

    Or simply /TEMPLATE NAME if you use extension less URLs

    <a href="/logout">Logout</a>

Please Sign in or register to post replies

Write your reply to:

Draft