Auto-login after registration

Posted by Community Admin on 03-Aug-2018 15:24

Auto-login after registration

All Replies

Posted by Community Admin on 19-Mar-2013 00:00

Is there a way to configure Sitefinity to automatically login a new user when they submit the form on the Registration widget?  This seems like something that would be a common practice for many sites.  I'm running Sitefinity 5.4 with claims authentication.

Posted by Community Admin on 20-Mar-2013 00:00

Hallo
This is a feature that we would also like to know.
Thanks Rich for asking this :-)

Kind regards
Henrik Stensgaard

Posted by Community Admin on 21-Mar-2013 00:00

Hello guys,

 There is currently no configuration for this, but you can implement it by inheriting the RegistrationForm control and overriding the ConfirmRegistration method. You have the user there, so you can get all the parameters you need to authenticate the user through the SecurityManager.
Here's a sample code for this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Telerik.Sitefinity.Security;
using Telerik.Sitefinity.Security.Web.UI;
 
namespace SitefinityWebApp
    public class RegistrationFormCustom : RegistrationForm
    
        protected override void ConfirmRegistration(Telerik.Sitefinity.Security.UserManager userManager, Telerik.Sitefinity.Security.Model.User user)
        
            base.ConfirmRegistration(userManager, user);
            SecurityManager.AuthenticateUser(user.ProviderName, user.UserName, user.Password, true );
        
    

Let me know if you have further questions.

All the best,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested 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 09-Apr-2013 00:00

I get the idea behind this but the main question I have it where do I actually put that code? in a custom control? in a class? Where does that go to inherit from the base registration?

Posted by Community Admin on 11-Apr-2013 00:00

I now understand what exactly I need to do with this however the user cookie is never created.

I just got the UserLoggingReason to spit back so I could see what was happening and it is saying the user or password is wrong.  

I would imagine because Authenticate user is expecting a plain text string for the password but the user.password is already encrypted.  How can I get the plain text password from here?

Posted by Community Admin on 12-Apr-2013 00:00

Hello Rick,

Achieving the desired functionality is quite easy if you override the default RegistrationForm widget, and plug in to the ConfirmRegistration method, where you have the newly created user passed as an argument. The only additional thing you will need to take into account is that the password of the user should be retrieved from the value of the textbox the user has filled in, rather than the User object.
here's a brief example of what I've explained above:

public class RegistrationFormAutoLogin : RegistrationForm
    
        protected override void ConfirmRegistration(Telerik.Sitefinity.Security.UserManager userManager, Telerik.Sitefinity.Security.Model.User user)
        
            base.ConfirmRegistration(userManager, user);
            SecurityManager.AuthenticateUser(user.ProviderName, user.UserName, (string)this.PasswordField.Value, true);
        
    
For your convenience I've also recorded a short video demonstrating how this functionality works on my local project, hope you find it useful.

All the best,
Boyan Barnev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested 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-May-2013 00:00

Hi,

I tried the method explained in this post. I created one .cs file and inherited RegistrationForm. But don't know why its not even calling my custom class. Any ideas?? Am I missing anything in my code or settings??

Please reply.

Thanks,
Surbhi Agarwal

Posted by Community Admin on 09-May-2013 00:00

Hi Surbhi,

Once you build your new class you need to register it in the Toolbox. I recommend using Thunder for that. Then you have a widget that you can drop onto a page instead of the default Registration widget.

I hope that helps.

Regards,
Randy Hodge
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested 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 09-May-2013 00:00

Hi Randy,

Thanks for the reply. But, I am trying not to create the whole new registration form with all functionality. Just wanted to update the username with email address for that user. The method you mentioned invloves creating a whole new registration widget.

Is there any way by which I can do this?

Thanks,
Surbhi Agarwal

Posted by Community Admin on 14-May-2013 00:00

Hello Surbhi,

You have already created a whole new widget when you made a class that inherits from RegistrationForm. That's what inheritance is all about. You cannot change the actual RegistrationForm; it is compiled into an assembly and you have no source code to recompile it. So you make your own version that is exactly the same (through inheritance) except for the parts you want to behave differently. Then you must tell Sitefinity to use your class by registering it in the Toolbox and use it instead of the default RegistrationForm.

I hope this clarifies things for you.

Regards,
Randy Hodge
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested 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 24-Dec-2013 00:00

I Implemented this solution and it works but how do change the designer display from the display a label  (from creating a new widget) to the Registration designer as shown in Boyan's video?

Thanks!

Posted by Community Admin on 27-Dec-2013 00:00

Hello,

If I understand correctly your idea, this should be your solution:

In the Custom Registration Form you override LayouthTemplatePath which should be the path to some custom .ascx template which is using RegistrationForm.cs. This should be some template which should be modified from the original one - RegistrationForm.ascx

Hope this will help.



Regards,
Ivan A. Petrov
Telerik

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested 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 27-Dec-2013 00:00

Ivan,

Thanks for your help, but I guess I did not explain myself clearly. 

I need to override the Designer control. My RegistrationAutoLoginDesigner.cs has the code below and I need to make into the standard widget's "RegistrationFormDesigner.cs" . 

<%@ Control %>
<%@ Register Assembly="Telerik.Sitefinity" TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" %>
<%@ Register Assembly="Telerik.Sitefinity" TagPrefix="sitefinity" Namespace="Telerik.Sitefinity.Web.UI" %>
<%@ Register Assembly="Telerik.Sitefinity" TagPrefix="sfFields" Namespace="Telerik.Sitefinity.Web.UI.Fields" %>
 
<sitefinity:ResourceLinks ID="resourcesLinks" runat="server">
    <sitefinity:ResourceFile Name="Styles/Ajax.css" />
</sitefinity:ResourceLinks>
<div id="designerLayoutRoot" class="sfContentViews sfSingleContentView" style="max-height: 400px; overflow: auto; ">
<ol>       
    <li class="sfFormCtrl">
    <asp:Label runat="server" AssociatedControlID="Message" CssClass="sfTxtLbl">Message</asp:Label>
    <asp:TextBox ID="Message" runat="server" CssClass="sfTxt" />
    <div class="sfExample">The label's message</div>
    </li>
     
</ol>
</div>

This thread is closed