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

Forums / General Discussions / Auto-login after registration

Auto-login after registration

13 posts, 0 answered
  1. Rich
    Rich avatar
    24 posts
    Registered:
    22 Oct 2012
    19 Mar 2013
    Link to this post
    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.
  2. Henriette
    Henriette avatar
    41 posts
    Registered:
    20 Aug 2009
    20 Mar 2013
    Link to this post
    Hallo
    This is a feature that we would also like to know.
    Thanks Rich for asking this :-)

    Kind regards
    Henrik Stensgaard
  3. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    21 Mar 2013
    Link to this post
    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
  4. Rick
    Rick avatar
    32 posts
    Registered:
    13 Dec 2006
    09 Apr 2013 in reply to Svetoslav Petsov
    Link to this post
    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?
  5. Rick
    Rick avatar
    32 posts
    Registered:
    13 Dec 2006
    11 Apr 2013 in reply to Rick
    Link to this post
    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?
  6. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    08 Dec 2016
    12 Apr 2013
    Link to this post
    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
  7. Surbhi
    Surbhi avatar
    4 posts
    Registered:
    23 May 2012
    07 May 2013 in reply to Boyan Barnev
    Link to this post
    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
  8. Randy Hodge
    Randy Hodge avatar
    96 posts
    Registered:
    03 Nov 2014
    09 May 2013
    Link to this post
    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
  9. Surbhi
    Surbhi avatar
    4 posts
    Registered:
    23 May 2012
    09 May 2013 in reply to Randy Hodge
    Link to this post
    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
  10. Randy Hodge
    Randy Hodge avatar
    96 posts
    Registered:
    03 Nov 2014
    14 May 2013
    Link to this post
    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
  11. Highrad
    Highrad avatar
    15 posts
    Registered:
    22 Aug 2007
    24 Dec 2013
    Link to this post
    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!
  12. Ivan A. Petrov
    Ivan A. Petrov avatar
    8 posts
    Registered:
    09 Sep 2013
    27 Dec 2013
    Link to this post
    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
  13. Highrad
    Highrad avatar
    15 posts
    Registered:
    22 Aug 2007
    27 Dec 2013 in reply to Ivan A. Petrov
    Link to this post
    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>
13 posts, 0 answered