Copied to clipboard

Flag this post as spam?

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


  • Antonio Amézquita 35 posts 52 karma points
    Jun 08, 2011 @ 09:26
    Antonio Amézquita
    0

    2 step member login with ASP.NET login control?

    Hi everybody

    Need some help implementing an member login with ASP.NET login control,

    Here is the scenario:

    Step 1 a lightbox presents a login formular .

    Step 2 when the members is logged on, is presented a disclaimer that upon acceptance redirects him to to the logged in area.

    Any help how to achieve this?

     

    Here is the code:

    <script runat="server">
            void SiteSpecificUserLoggingMethod(string UserName)
            {
                    // Insert code to record the current date and time
                    // when this user was authenticated at the site.
            }
       
            void OnLoggedIn(object sender, EventArgs e)
            {
                    SiteSpecificUserLoggingMethod(Login1.UserName);
            }
       
            bool IsValidEmail(string strIn)
            {
                // Return true if strIn is in valid e-mail format.
                return Regex.IsMatch(strIn, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
            }
           
            void OnLoggingIn(object sender, System.Web.UI.WebControls.LoginCancelEventArgs e)
            {
                if (!IsValidEmail(Login1.UserName))
                {
                    Login1.InstructionText = "You must enter a valid e-mail address.";
                    e.Cancel = true;
                }
                else
                {
                    Login1.InstructionText = String.Empty;
                }
            }   
        </script>

    <asp:Login ID="Login1" runat="server"
                DisplayRememberMe="False"
                TitleText="Log on here"
                DestinationPageUrl="somewhere"
                orientation="Horizontal"
                          textlayout="TextOnTop"
                UserNameLabelText="USERNAME:"
                PasswordLabelText="PASSWORD:"
                OnLoggingIn="OnLoggingIn"
                OnLoggedIn="OnLoggedIn">
                    <TitleTextStyle Font-Bold="True" ForeColor="#000000" BackColor="#FFFFFF"></TitleTextStyle>
            </asp:Login>

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Jun 08, 2011 @ 10:08
    Michael Latouche
    0

    Hi Antonio,

    I'm not sure you need to record the last login date and time in your method SiteSpecificUserLoggingMethod, as this is normally accessible throughout the site via Membership.GetUser() which will return the current logged in user, which has properties for determining last login, etc. So my guess is you can just redirect to your acceptance page from here.

    Then for the acceptance of conditions, I would save a flag (cookie, session, property if it needs to be accecpted only once and not at each login) indicating if the conditions have been accepted or not.

    In your logged in area page template(s), I would then make a check in the OnLoad event to make sure the person accessing the page has logged in and has accepted the terms and conditions. So Something like this, if we suppose you save the acceptance flag in the session:

    if (Membership.GetUser() == null || !(bool)Session["hasAccpetedConditions"])
    Response.Redirect ("~/noAccess.aspx");

    Hope this helps setting you on track.

    Cheers,

    Michael.

  • Antonio Amézquita 35 posts 52 karma points
    Jun 08, 2011 @ 20:09
    Antonio Amézquita
    0

    Hi Michael

     

    Thank you much for your answer, my Asp.Net understanding is null, so the project has been ussigned to another person.

    Thanks again for your suggestions.

     

    Cheers

    Antonio

Please Sign in or register to post replies

Write your reply to:

Draft