Search, User Login, Registration

Posted by Community Admin on 03-Aug-2018 11:44

Search, User Login, Registration

All Replies

Posted by Community Admin on 15-Sep-2010 00:00

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

Posted by Community Admin on 15-Sep-2010 00:00

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

Posted by Community Admin on 29-Sep-2010 00:00

"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?

Posted by Community Admin on 29-Sep-2010 00:00

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

Posted by Community Admin on 29-Sep-2010 00:00

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

Posted by Community Admin on 06-Oct-2010 00:00

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.

Posted by Community Admin on 06-Oct-2010 00:00

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

Posted by Community Admin on 06-Oct-2010 00:00

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.

Posted by Community Admin on 06-Oct-2010 00:00

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

Posted by Community Admin on 07-Oct-2010 00:00

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.

Posted by Community Admin on 07-Oct-2010 00:00

Just needed to set the DestinationPageUrl !

 

lf.DestinationPageUrl = "/page";

Posted by Community Admin on 18-Oct-2010 00:00

Ivan,


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

Many thanks,
Andrei

Posted by Community Admin on 18-Oct-2010 00:00

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

Posted by Community Admin on 19-Nov-2010 00:00

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


Posted by Community Admin on 19-Nov-2010 00:00

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 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

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

Posted by Community Admin on 19-Nov-2010 00:00

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

Posted by Community Admin on 14-Dec-2010 00:00

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

Posted by Community Admin on 14-Dec-2010 00:00

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

Posted by Community Admin on 14-Dec-2010 00:00

Ivan,

I was just having a look at:
www.sitefinity.com/.../reply-thread.aspx
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

Posted by Community Admin on 14-Dec-2010 00:00

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

Posted by Community Admin on 14-Dec-2010 00:00

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

Posted by Community Admin on 15-Dec-2010 00:00

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

Posted by Community Admin on 16-Dec-2010 00:00

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

Posted by Community Admin on 16-Dec-2010 00:00

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

Posted by Community Admin on 16-Dec-2010 00:00

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

Posted by Community Admin on 16-Dec-2010 00:00

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 

Posted by Community Admin on 16-Dec-2010 00:00

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

Posted by Community Admin on 16-Dec-2010 00:00

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

Posted by Community Admin on 04-Jan-2011 00:00

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


Posted by Community Admin on 04-Jan-2011 00:00

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

Posted by Community Admin on 04-Jan-2011 00:00

Ivan,

Firstly, just to say that the link in the email 'Click here to post a reply.....' did not work. Not sure why.

Secondly thanks for the explanation, I will give it a go and let you know.

Thirdly, how safe is it to develop against the RC? Is it worth waiting?

Many thanks again,
Andrei

Posted by Community Admin on 04-Jan-2011 00:00

Hi,

Our web team will check what the problem is with "Click here to post a reply.....". We make make changes to the code everyday, because we are fixing bugs and we are re factoring entire code base for the official release. Currently you can use AuthenticateUser   method which can be accessed.

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

Posted by Community Admin on 21-Jan-2011 00:00

Ivan,

In the latest version I can not find the 'LoginToManage' label in the Labels module. How do I change the 'Login to manage this site message in the latest version?

Many thanks,
Andrei

Posted by Community Admin on 21-Jan-2011 00:00

Ivan,

Sorry, I found the Label. I was typing "logintomanage" rather than "LoginToManage". I did not know that I should get the upper and lower case as well. Although..., why??? Your RegEx should do that.

Anyway, sorry again.
Andrei

This thread is closed