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

Forums / General Discussions / Search, User Login, Registration

Search, User Login, Registration

34 posts, 0 answered
  1. Peppi Alexandrova
    Peppi Alexandrova avatar
    14 posts
    Registered:
    22 Feb 2006
    15 Sep 2010
    Link to this post
    Hi I see these features are missing in 4.0 beta, or maybe I can't find them?
    Can I have user login and registration?
    What about advanced search?

    Thanks,
    Peppi
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Sep 2010
    Link to this post
    Hello Peppi Alexandrova,

    Search providers have not been implemented yet. You can use ASP.NET Login and CreateUserWizard controls to authenticate existing users or create new users.

    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
  3. Joe Keller
    Joe Keller avatar
    48 posts
    Registered:
    07 Apr 2010
    29 Sep 2010
    Link to this post
    "You can use ASP.NET Login and CreateUserWizard controls to authenticate existing users or create new users."

    I don's see these controls as part of the tool bar.

    Does this mean that there will not be any out-of-the-box controls for login or registration?
    Does this also mean that in-order to provide a log or registration for the site you have to create a custom module?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    29 Sep 2010
    Link to this post
    Hi Joe,

    Here is what you can do. You can crate a simple user control and there declare LoginForm control. Then you can use this widget to authenticate your users.

    <%@ Register TagPrefix="log" Namespace="Telerik.Sitefinity.Security.Web.UI" Assembly="Telerik.Sitefinity" %>
     
     
    <log:LoginForm  runat="server" ID="LogForm1" />

    Another option is generating the authentication in ASP.NET Login control.

    SecurityManager.SetAuthenticationCookie(SystemManager.CurrentHttpContext, user.ProviderName, user, true)


    Best wishes,
    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
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    29 Sep 2010
    Link to this post
    Hi Joe Keller,

    To register a new user you can use CreateUserWizardForm, but the current implementation will not allow you to create a user if you do not have permissions for "Create"

    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
  6. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    06 Oct 2010
    Link to this post
    When trying to create the control in design mode i get

    Error Creating Control - LogForm1
    the type initializer for 'Telerik.Sitefinity.Security.SecurityManager' threw an exception.
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    06 Oct 2010
    Link to this post
    Hello Kristian,

    I saw what the problem was. Inside Page Edit mode there is no this.Page.Form that we use inside CreateUserWizardForm control - OnPreRender method.

    You can create the control in the code behind and add it to the controls collection

    var cuwf = new Telerik.Sitefinity.Security.Web.UI.CreateUserWizardForm();
    if (!cuwf.IsDesignMode() && !cuwf.IsBackend())
    {
        
    }

    or check the Page.IsBackend() and Page.IsDesignMode() and clear the controls collection.

    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
  8. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    06 Oct 2010
    Link to this post
    Thanks!

    Since, I am using the LoginForm control. Now that I am adding it using code how would I do a redirect to another page?

    Leaving the control as is the control ends up displaying:

    Object moved to here.

  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    06 Oct 2010
    Link to this post
    Hello Kristian,

    Using the control as is posted does not make such redirect for me. Could you drop the control on a page (without ) any other controls and let me know the steps that lead to "object moved"

    Object moved generally appears when you change the host or your are making some domain/newtwork routings. We use the same control for backend logging, so getting this error on the public instance would be equivalent to getting the "object moved" when you try to access the backend.

    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
  10. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    07 Oct 2010
    Link to this post
    Here is my code

    Login.ascx
    <asp:Panel ID="Panel1" runat="server">
    </asp:Panel>

    Login.ascx.cs
    protected void Page_Load(object sender, EventArgs e)
    {
        var lf = new Telerik.Sitefinity.Security.Web.UI.LoginForm();
          
        Panel1.Controls.Add(lf);
    }

    I drop the control onto a page, then when trying to login I get sent to the object moved page.
  11. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    07 Oct 2010
    Link to this post
    Just needed to set the DestinationPageUrl !

     

    lf.DestinationPageUrl = "/page";
  12. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    18 Oct 2010
    Link to this post
    Ivan,

    I am trying this solution, but it removes all the styling. Not sure why?

    Many thanks,
    Andrei
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Oct 2010
    Link to this post
    Hi Andrey,

    The control is getting styles from the current theme stylesheet. You can use ResourceLinks to style the control

    <sf:ResourceLinks id="resourceLinks" runat="server">
                <sf:ResourceFile Name="CSS/test1.css" />
    </sf:ResourceLinks>


    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
  14. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    19 Nov 2010
    Link to this post
    Ivan,

    I am glad to see the Login Control in the RC version. I have dropped it onto a page and started
    playing around with it. The following are my questions:
    1 - Many of the properties like the DestinationPageUrl do not have a button to select the page from the SiteMap, rather you have to type it in. The same goes for Boolean properties and so on.
    2 - Does not give an option to change the "Login to manage the site." label.
    3 - I set the "DisplayRememberMe" to False and it does not get reflected on the FrontEnd.

    That's all for now. I know you are getting bombarded now so take your time.

    Many thanks and well done in keeping up with all of us,
    Andrei


  15. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    19 Nov 2010
    Link to this post
    Hello Andrei,

    Yes, we promised to implement these controls and now you see them in your toolbox.

    1. We will work on selectors and I hope that we will have them for the official release.

    2. "Login to manage the site" - this could be changes from Sitefinity >> Administration >> Labels where the key is Key: LoginToManage .
    Another option here is using of the Login control - Sitefinity >> Administration >> Settings >> Advanced >> Toolboxes >> PageControls >> Sections >> Login.

    You can create a custom label and set its from  Sitefinity >> Administration >> Labels

    3. This is a bug that we logged for fixing. Your Telerik points have been updated.

    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
  16. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    19 Nov 2010
    Link to this post
    Ivan,

    Many thanks for the reply and the points. 

    2. "Login to manage the site" - this could be changes from Sitefinity >> Administration >> Labels where the key is Key: LoginToManage .
    Another option here is using ResourceClassId of the Login control - Sitefinity >> Administration >> Settings >> Advanced >> Toolboxes >> PageControls >> Sections >> Login.
    You can create a custom label and set its ResourceClassId from  Sitefinity >> Administration >> Labels

    By 'Labels' I guess you mean 'Interface Lables & Messages'.

    I typed in the search box at the top 'LoginToManage' and one result came up. I clicked on it and it took me to the edit window, but I could not see anything there. So I found that I have to sort the one result by date and then by alphabet again and then when I click on it to edit it, the edit form shows the editor. So I think it is a bug.

    Ok I changed the 'Login to manage the site'  text to 'Login', saved it and the login control still shows the original label. I will attempt the other suggestion. As I said, the Login Control looses all its styling when viewed via the FrontEnd and so that might be the cause. 

    Many thanks,
    Andrei
    ---------------------
    Ivan,

    I tried again, but this time I changed the label and then switched off everything. Went back and it works.
    So not sure why it did not work last time.

    Many thanks,
    Andrei
  17. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    14 Dec 2010
    Link to this post
    Ivan,

    For some reason in build 4.0.992.0 I get kicked out when I use the code:
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.Page.IsBackend() && !this.Page.IsDesignMode())
            {
                // get the login button
                var b = this.LoginForm.FindControl("LoginButton") as Button;
                // subscribe for click event
                b.Click += new EventHandler(b_Click);
                // get the current user 
                var user = SecurityManager.GetCurrentUser();
                if (user != null)
                {
                    // get the identity
                    var ident = user.Identity.Name;
                    // force log out for this stest
                    SecurityManager.Logout();
                }
            }
    }

    Does not register that I am in the backend, logs me out and says "Server Session Expired". Could you try it out please?

    Also I tried:
    if (!this.LoginForm.IsBackend() && !this.LoginForm.IsDesignMode())

    And still the same.

    Many thanks,
    Andrei
  18. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    14 Dec 2010
    Link to this post
    Hello Andrei,

    Could you try to use this.IsDesignMode() instead of this.Page.IsDesignMode().
    IsDesignMode() is a control extension method from System.Web.UI.ControlExtensions

    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
  19. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    14 Dec 2010
    Link to this post
    Ivan,

    I was just having a look at:
    http://www.sitefinity.com/devnet/forums/reply-thread.aspx?messageId=0&threadId=371120

    where you recommend the same thing. I have already tried it and it did not work. I have some code which writes into a database when someone has accessed a page. So i do not want it to write anything in the database when the page is accessed from the backend.

    So I opened the project in Visual Studio 2010 and set ~/Sitefinity/Default.aspx as the Starting page. Put a breakpoint inside the if statement and attempted to access the page with the code from the Backend. The breakpoint gets hit twice for some reason. First time it gets hit, it works. The second time it gets hit it doesn't. All I do is click the page to edit it. Until it loads in design mode, the code is run through twice. First time it does not write anything to the database, the second time it writes to the database.

    Any further thoughts?

    Many thanks,
    Andrei

    Or this link, is the same.
    http://www.sitefinity.com/devnet/forums/sitefinity-4-x/sdk/how-to-know-that-we-are-in-edit-mode.aspx#0
  20. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    14 Dec 2010
    Link to this post
    Hello Andrei,

    I am not able to replicate the issue locally when the code runs in Page_Load event of a user control. For controls that inherit from SimpleView you should use InitializeControls. You could try using try using OR condition instead of AND so that both cases - design and backend will be covered.

    Best wishes,
    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
  21. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    14 Dec 2010
    Link to this post
    Ivan,

    The code is:
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UserName.ascx.cs" Inherits="SitefinityWebApp.Controls.UserName" %>
    <p>Welcome <asp:LoginName ID="LoginName" runat="server" /> [<asp:LoginStatus 
            ID="LoginStatus" runat="server" onloggingout="LoginStatus_LoggingOut" />]</p>

    using System;
    using System.Web.UI.WebControls;
    using System.Web.UI;
    using System.Data.SqlClient;
    using System.Data;
    using Telerik.Sitefinity.Security;
    using Telerik.Sitefinity.Web.UI;
      
    namespace SitefinityWebApp.Controls
    {
        public partial class UserName : System.Web.UI.UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!this.IsBackend() && !this.IsDesignMode())
                    {
                        if (!string.IsNullOrEmpty(_connectionString))
                        {RecordUser();}
                    
            }
      
            protected void LoginStatus_LoggingOut(object sender, LoginCancelEventArgs e)
            {
                Server.Transfer("~/Default");
            }
      
            private void RecordUser()
            {
                SqlConnection connection = new SqlConnection(ConnectionString);
                connection.Open();
      
                try
                {
                    SqlCommand command = new SqlCommand("INSERT INTO Report (UserName, TimeRead) VALUES (@username, @timeread);", connection);
                    command.CommandType = System.Data.CommandType.Text;
                    command.Parameters.Add(new SqlParameter("@username", SqlDbType.NVarChar, 50)).Value = SecurityManager.GetCurrentUser().Identity.Name;
                    command.Parameters.Add(new SqlParameter("@timeread", SqlDbType.DateTime2)).Value = DateTime.Now;
                    command.ExecuteNonQuery();
                }
                finally { if (!(connection.State == ConnectionState.Closed)) {connection.Close();} }
                }
      
            private string _connectionString = "";
            public string ConnectionString
            {
                get {return _connectionString;}
                set {_connectionString = value;}
            }
        }
    }

    I have already tried teh || (OR) option and did not work either. Is it time to scrap another project and start afresh? Can you elaborate on the 'InitializeControls' based on my code above.

    Many thanks again,
    Andrei
  22. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Dec 2010
    Link to this post
    Hello Andrei,

    I am not able to replicate the issue with this.IsBackend() and this.IsDesignMode(). We use these extensions in our code as well and so far they apply without issues. Can you replicate the problem with a new project with the latest build?

    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
  23. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    16 Dec 2010
    Link to this post
    Ivan,

    Yes I replicated the issue in a new project. I wish I had a way of creating videos like you do. What do you use? I don't have the full Adobe Acrobat on my machine but I see a few Open Source applications. Until I figure the video bit out, see my code below.
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CustomLogin.ascx.cs" Inherits="SitefinityWebApp.Controls.CustomLogin" %>
      
    <div align="center">
        <asp:Login ID="LoginForm" runat="server" BackColor="#F7F6F3" BorderColor="#E6E2D8" 
            BorderStyle="Solid" BorderWidth="1px" DisplayRememberMe="False" 
            Font-Names="Verdana" Height="150px" Width="350px" 
                BorderPadding="4" ForeColor="#333333">
                 
            <LabelStyle Font-Size="1.4em"/>
            <InstructionTextStyle Font-Italic="True" ForeColor="Black"  Font-Size="3em" />
            <LoginButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid" 
                BorderWidth="1px" Font-Names="Verdana" Font-Size="1.5em" ForeColor="#284775" />
            <TextBoxStyle Font-Size="1.5em" Width="200px" />
            <TitleTextStyle  BackColor="black" Font-Bold="True" ForeColor="#FFFFFF" Font-Size="2em" />
        </asp:Login>
    </div>

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Sitefinity.Security;
    using Telerik.Sitefinity.Services;
    using System.Data.SqlClient;
    using System.Data;
      
    namespace SitefinityWebApp.Controls
    {
        public partial class CustomLogin : System.Web.UI.UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!this.IsBackend() && !this.IsDesignMode())
                    {
                        // get the login button
                        var b = this.LoginForm.FindControl("LoginButton") as Button;
                        // subscribe for click event
                        b.Click += new EventHandler(b_Click);
                        // get the current user 
                        var user = SecurityManager.GetCurrentUser();
                        if (user != null)
                        {
                            // get the identity
                            var ident = user.Identity.Name;
                            // force log out for this test
                            SecurityManager.Logout();
                        }
                    }
            }
      
            void b_Click(object sender, EventArgs e)
            {
                // Login the user.
                var now = DateTime.UtcNow;
                var ip = SystemManager.CurrentHttpContext.Request.UserHostAddress;
                var manager = UserManager.GetManager();
                var user = manager.GetUser(LoginForm.UserName);
                user.IsLoggedIn = true;
                user.LastLoginIp = ip;
                user.LastLoginDate = now;
                user.LastActivityDate = now;
                SecurityManager.SetAuthenticationCookie(SystemManager.CurrentHttpContext.Response, "Default", user, true);
                manager.Provider.SuppressSecurityChecks = true;
                manager.SaveChanges();
                manager.Provider.SuppressSecurityChecks = false;
                if (!string.IsNullOrEmpty(_connectionString))
                { RecordUser(LoginForm.UserName); }
                Response.Redirect(_destinationPageUrl);
            }
      
            private void RecordUser(string username)
            {
                SqlConnection connection = new SqlConnection(ConnectionString);
                connection.Open();
      
                try
                {
                    SqlCommand command = new SqlCommand("INSERT INTO Report (UserName, TimeRead) VALUES (@username, @timeread);", connection);
                    command.CommandType = System.Data.CommandType.Text;
                    command.Parameters.Add(new SqlParameter("@username", SqlDbType.NVarChar, 50)).Value = username;
                    command.Parameters.Add(new SqlParameter("@timeread", SqlDbType.DateTime2)).Value = DateTime.Now;
                    command.ExecuteNonQuery();
                }
                finally { if (!(connection.State == ConnectionState.Closed)) { connection.Close(); } }
            }
      
            private string _connectionString = "";
            public string ConnectionString
            {
                get { return _connectionString; }
                set { _connectionString = value; }
            }
      
            private string _destinationPageUrl = "~/Default.aspx";
            public string DestinationPageUrl
            {
                get {return _destinationPageUrl;}
                set {_destinationPageUrl = value;}
            }
        }
    }

    We do not develop here in C# but this is me having a go. I know I can do these controls in VB too, but its not too hard to have them done in C#.

    I will see about the video and get back to you.

    Many thanks,
    Andrei

  24. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    16 Dec 2010
    Link to this post
    Ivan,

    I got hold of an application and did a video for you but I can't attach it because .zip files are not allowed. Also, its bigger than 2MB. Its actually 13MB.
    Can I email it to you?

    Many thanks,
    Andrei
  25. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Dec 2010
    Link to this post
    Hello Andrei,

    Again, there is no issue at my end with your code. You can host your video somewhere and I will check it.

    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
  26. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    16 Dec 2010
    Link to this post
    Ivan,

    Here is the link: https://www.transferbigfiles.com/47030b13-6e6b-4020-a48d-86d03d2a9ce4?rid=nw5c%2fw2kiydsyhFpcrhSUg%3d%3d

    Hopefully, it will prove that I am not going crazy, because I am really lost for words. Your video demonstrates that it is working.

    Let me know.

    Many thanks again,
    Andrei 
  27. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Dec 2010
    Link to this post
    Hello Andrei,

    We had similar bug that appears only in IE. There should not be an issue if you use FireFox.  We fixed the issue and the fix will appear in the weekly build that we will have next week.

    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
  28. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    16 Dec 2010
    Link to this post
    Ivan,

    That answers it. I am not very big on IE either, but because our customers use it, I must develop against it.
    Thank you very much again.
    Andrei
  29. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    04 Jan 2011
    Link to this post
    Ivan,

    I have downloaded the latest version of the RC (1030) and when compiling my Login Control I get the following

    Telerik.Sitefinity.Security.SecurityManager' does not contain a definition for 'SetAuthenticationCookie

    I checked the class and indeed SetAuthenticationCookie does not exist. What happened and what do I use now?

    Many thanks,
    Andrei

  30. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    04 Jan 2011
    Link to this post
    Hi,

    We made the method internal.  You can use our Login control implemented with the RC release, try using AuthenticateUser  or follow this post to authenticate the user by using web request.

    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
34 posts, 0 answered
1 2