p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Umbraco User's Guide (http://p2p.wrox.com/forumdisplay.php?f=641)
-   -   Login Macro (http://p2p.wrox.com/showthread.php?t=90765)

scorpio26krf August 28th, 2013 02:24 PM

Login Macro
 
Hi All -

You can find the Login Macro on Page 244 - 246.

I have a client using Umbraco 4.7.1. They requested a login page for board members. I followed the book: made the required web.config change (DefaultMemberTypeAlias attribute match one of my configured Member types). Then I created the login.ascx page, copied the code from the book on the front end and code behind pages(see below). I compiled, went into Umbraco and created the login Macro, told it to use the .NET User Control Login.ascx. Then I added that Macro to a page. Added a protected page, told the protected page to go to the page with the login macro as a login page. It goes to the correct page, and I can see the control fine. However, nothing happens when I click 'login'. I have a user created. Any guidance would be helpful.

Login.ascx
Code:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Login.ascx.cs" Inherits="LifeSkills.usercontrols.Login" %>
<asp:Login ID="_loginForm" runat="server">
</asp:Login>

Login.ascx.cs
Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LifeSkills.usercontrols
{
    public partial class Login : System.Web.UI.UserControl
    {
        //The default redirect page after loggin in
        public int LoginRedirectPage { get; set; }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            _loginForm.LoggedIn += LoginUser_LoggedIn;
        }

        //When the user has successfully authenticated redirect to the specified page
        void LoginUser_LoggedIn(object sender, EventArgs e)
        {
            Response.Redirect(umbraco.library.NiceUrl(LoginRedirectPage));
        }

        protected void Page_Load(object sender, EventArgs e)
        {
        }
    }
}


scorpio26krf August 29th, 2013 12:28 PM

Hey Everyone,

I figured out my issue. The previous vender for this client had nested form tags on the master page that was causing no postback on my button click. Found help with this forum: http://our.umbraco.org/forum/core/ge...ontrol-Umbraco

scorpio26krf August 29th, 2013 02:24 PM

Working but not redirecting
 
I have the login working now[:D]

Now my issue is, though I am logged in, I am still redirected to the login page with the control still there, so I think I still need to log in. I realized that I was logged in when I tried to go to the protected page and it loaded with no error/login page showing.

Is the redirect now working or is it not correct? Shouldn't the "LoginRedirectPage" have a value of my protected page?


All times are GMT -4. The time now is 08:56 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.