Most appropriate place in the API to take action when a user

Posted by Community Admin on 04-Aug-2018 21:06

Most appropriate place in the API to take action when a user is created, modified, or deleted

All Replies

Posted by Community Admin on 29-Dec-2011 00:00

We have some actions that need to take place any time a user is created, modified, or deleted. Does Sitefinity 4 provide any sort of global event that can be handled when actions on a user account occur? We'd prefer not to create new versions of the various signup and user edit forms in the front- and backend. I've looked at the various managers in Telerik.Sitefinity.Security and none of them seem to fire any such events. Hopefully I'm missing something.

Thanks!

Posted by Community Admin on 03-Jan-2012 00:00

Hello,

There are no such events provided by the Usermanager and SecurityManager. Excuse us for the inconvenience. 
As a workaround create a class in your project and inherit from Telerik.Sitefinity.Security.Web.UI.RegistrationForm. Place this as a .cs file in your project and register as a new custom control. Go to Administration->Settings->Advanced->Toolboxes choose at which section to register and use Namespace.Class for registration. When you inherit the template for the control will be the same as the registration control, but you will be able to override the existing methods and inject new logic.

using System;
  
using System.Collections.Generic;
  
using System.Linq;
  
using System.Web;
  
  
  
namespace SitefinityWebApp.Custom
  
  
    public class Class1 : Telerik.Sitefinity.Security.Web.UI.RegistrationForm
  
    
  
         
    
  

Register with SitefinityWebApp.Custom.Class1 in my case (namespace class).

Kind regards,
Stanislav Velikov
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 03-Jan-2012 00:00

Thanks for the reply. We were hoping to avoid having add custom controls, as we need to execute code every time a user is modified or deleted... not just when a user signs up. This includes actions taken from the backend as well, meaning multiple controls would need to be overridden and replaced in user management section of the admin side.

But now at least we know that this is the only approach.

Posted by Community Admin on 19-Jan-2012 00:00

We also need to capture changes to user accounts in the backend, including adding, editing, and deleting users. We figured that we would do something similar to what you suggest for the front end control (inherit from the controls used for user management on the backend and replace the existing ones) but we're having difficulty even figuring out which control to override. The backend control appears to not be as straightforward.

Is there any advice for this? Really, all we want to do is execute some code whenever a change is made to a user account

Posted by Community Admin on 23-Jan-2012 00:00

Hi,

 For the registration form when new user registers this method can be used to add new logic. Here is the default one:

protected virtual void RegisterButton_Click(object sender, EventArgs e)
        
            if (this.ValidateInput())
            
                var userManager = UserManager.GetManager(this.MembershipProvider);
                User user;
                MembershipCreateStatus status;
                var userProviderSuppressSecurityChecks = userManager.Provider.SuppressSecurityChecks;
                try
                
                    LoginCancelEventArgs creatingUserArgs = this.OnCreatingUser();
                    if (!creatingUserArgs.Cancel)
                    
                        userManager.Provider.SuppressSecurityChecks = true;
                        if (this.TryCreateUser(userManager, out user, out status))
                        
                            this.UpdateUserInformation(user);
                            userManager.SaveChanges();
                            this.OnUserCreated();
 
                            this.CreateUserProfiles(user);
 
                            this.AssignRolesToUser(user);
 
                            this.ConfirmRegistration(userManager, user);
                            this.ExecuteUserProfileSuccessfullUpdateActions();
                        
                        else
                        
                            this.OnUserCreationError(status);                         
                            this.ShowErrorMessage(status, userManager);
                        
                    
                
                catch (Exception)
                
                    throw;
                
                finally
                
                    userManager.Provider.SuppressSecurityChecks = userProviderSuppressSecurityChecks;
                
            
        

The users backend is a little more uncomfortable.
Create an .ascx file in your solution
<%@ Control Language="C#"  %>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sitefinity" %>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Modules.UserProfiles.Web.UI" TagPrefix="profiles" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<sitefinity:ResourceLinks id="resourcesLinks" runat="server">
<sitefinity:ResourceFile JavaScriptLibrary="JQuery"></sitefinity:ResourceFile>
</sitefinity:ResourceLinks>
<fieldset class="sfNewItemForm">
    <a href="javascript:CloseDialog();" class="sfBack"><asp:Literal runat="server" ID="lBackToUsers" Text='<%$ Resources:Labels, BackToUsers %>' /></a>
    <h1>
    <p>TTTTTTTTTTTTTAETAETAETAT</p>
        <asp:Literal ID="createAUserLiteral" runat="server" Text='<%$Resources:SecurityResources, CreateAUser %>'></asp:Literal>
    </h1>
     
    <sitefinity:Message ID="messageControl" runat="server"
        ElementTag="div" 
        CssClass="sfMessage sfDialogMessage"
        RemoveAfter="30000" 
        FadeDuration="10"
        OnClientLoad="messageControlLoaded" />
    <sitefinity:ClientLabelManager id="clientLabelManager" runat="server">
        <Labels>
            <sitefinity:ClientLabel ClassId="ErrorMessages" Key="CreateUserWizardDefaultUserNameRequiredErrorMessage" runat="server" />
            <sitefinity:ClientLabel ClassId="ErrorMessages" Key="CreateUserWizardDefaultPasswordRequiredErrorMessage" runat="server" />
            <sitefinity:ClientLabel ClassId="ErrorMessages" Key="CreateUserWizardDefaultEmailRegularExpressionErrorMessage" runat="server" />
            <sitefinity:ClientLabel ClassId="ErrorMessages" Key="CreateUserWizardDefaultConfirmPasswordRequiredErrorMessage" runat="server" />
            <sitefinity:ClientLabel ClassId="ErrorMessages" Key="CreateUserWizardDefaultConfirmPasswordCompareErrorMessage" runat="server" />
        </Labels>
    </sitefinity:ClientLabelManager>
     
    <div id="mainForm" runat="server">
    </div>
 
    <profiles:UserProfilesControl ID="profilesData" ViewKind="BackendCreate" runat="server" />
 
    <div class="sfForm">
        <div class="sfFormIn sfCheckBox">
            <asp:CheckBox ID="chkUserIsBackendUser" Text="<%$Resources:SecurityResources, ThisUserCanAccessSiteBackend %>" runat="server" />
            <div class="sfDescription"><asp:Literal ID="InOrderToManageContentOrSettingsLiteral" runat="server" Text='<%$Resources:SecurityResources, InOrderToManageContentOrSettings %>'></asp:Literal></div>
        </div>
    </div>
 
    <asp:Panel ID="providerPanel" runat="server">
        <fieldset class="sfForm">
            <div class="sfFormIn">
                <asp:Label ID="providerLabel" runat="server" CssClass="sfTxtLbl" AssociatedControlID="membershipProviderList" Text='<%$Resources:SecurityResources, Provider %>'></asp:Label>
                <asp:DropDownList ID="membershipProviderList" runat="server">
                </asp:DropDownList>
            </div>
        </fieldset>
    </asp:Panel>
    <!-- Repeater for the roles, instead of a binder. in order to better control which roles are displayed -->
    <fieldset class="sfForm">
    <div class="sfFormIn">
        <strong><asp:Literal ID="rolesLiteral" runat="server" Text='<%$Resources:SecurityResources, Roles %>' /></strong>
        <ol class="sfRolesList" id="rolesList" runat="server">     
        <asp:Repeater ID="rptRolesList" runat="server">
            <ItemTemplate>
                <li >
                    <asp:CheckBox ID="role" runat="server"  />
                    <asp:Label ID="lblRole" runat="server" />
                </li>
            </ItemTemplate>
        </asp:Repeater>
        </ol>
    </div>
    </fieldset>
     
    <asp:HiddenField ID="hCheckBoxesDetails" runat="server" />
     
    <div class="sfButtonArea sfMainFormBtns sfClearer" id="createNewUserButtonPanel">
        <a onclick="SaveChanges(true); return false;" class="sfLinkBtn sfSave">
            <strong class="sfLinkBtnIn">
                <asp:Literal ID="createThisUserLiteral" runat="server" Text='<%$Resources:SecurityResources, CreateThisUser %>'></asp:Literal>
            </strong>
        </a>
        <a onclick="SaveChanges(false); return false;" class="sfLinkBtn">
            <strong class="sfLinkBtnIn">
                <asp:Literal ID="createAndAddAnotherLiteral" runat="server" Text='<%$Resources:Labels, CreateAndAddAnother %>'></asp:Literal>
            </strong>
        </a>
        <span>
            <asp:Literal ID="orLiteral" runat="server" Text='<%$Resources:Labels, or %>'></asp:Literal>
        </span>
        <a href="javascript:CloseDialog();" class="sfCancel">
            <asp:Literal ID="cancelLiteral" runat="server" Text='<%$Resources:Labels, Cancel %>'></asp:Literal>
        </a>
    </div>
 
</fieldset>
 
<sitefinity:FormBinder ID="userFormBinder" runat="server" 
    TargetId="mainForm" 
    ServiceUrl="~/Sitefinity/Services/Security/Users.svc" 
    BindOnLoad="false" 
    OnClientDataBound="onDataBound"
    OnClientError="errorHandler"
    DataKeyNames="Id" 
    DataMembers="UserName, Password, Email, PasswordQuestion, PasswordAnswer, Comment, IsApproved"
    <Containers
        <sitefinity:BinderContainer ID="BinderContainer2" runat="server"
        <fieldset class="sfForm sfFirstForm">
            <ol class="sfFormIn">
            <li class="sfShortField180">
                <label for="UserName" class="sfTxtLbl">$Labels,Username$</label>
                <input type="text" id="UserName" name="UserName" class="sfTxt" />
            </li>
            <li class="sfShortField180">
                <label for="Password" class="sfTxtLbl">$ErrorMessages,LoginControlsDefaultPasswordLabelText$</label>
                <input type="password" id="Password" name="Password" class="sfTxt" />
                <p class="sfExample" id="PasswordExample"></p>
                <%--<p class="sfExample">At least <strong>7 characters</strong></p>--%>
            </li>
            <li class="sfShortField180">
                <label for="ConfirmPassword" class="sfTxtLbl">$ErrorMessages,CreateUserWizardDefaultConfirmPasswordLabelText$</label>
                <input type="password" id="ConfirmPassword" name="ConfirmPassword" class="sfTxt" />
            </li>
            <li class="sfTitleField sfShortField180">
                <label for="Email" class="sfTxtLbl">$ErrorMessages,CreateUserWizardDefaultEmailLabelText$</label>
                <input type="text" id="Email" name="Email" class="sfTxt" />
            </li>
            <li id="passwordanswersquestion" style="display:none;">
                <label for="PasswordQuestion" class="sfTxtLbl">$ErrorMessages,CreateUserWizardDefaultQuestionLabelText$</label>
                <input type="text" id="PasswordQuestion" name="PasswordQuestion" class="sfTxt" />
            </li>
            <li id="passwordanswersanswer" style="display:none;">
                <label for="PasswordAnswer" class="sfTxtLbl">$ErrorMessages, CreateUserWizardDefaultAnswerLabelText$</label>
                <input type="password" id="PasswordAnswer" name="PasswordAnswer" class="sfTxt" />
            </li>
            <li style="display:none;">
                <label for="Comment" class="sfTxtLbl">$Labels,UserCommentLabelText$</label>
                <textarea id="Comment" name="Comment" class="sfTxtArea"></textarea>
            </li>
            </ol>
        </fieldset>
        </sitefinity:BinderContainer
    </Containers>         
</sitefinity:FormBinder
 
<asp:HiddenField ID="usersServiceUrl" runat="server" />
<asp:HiddenField ID="newUserCreatedMessage" runat="server" Value='<%$Resources:SecurityResources, NewUserCreated %>' />
<asp:HiddenField ID="hfForceLogoutServiceUrl" runat="server" />
<asp:HiddenField ID="hBackendUsersRoleId" runat="server" />
<asp:HiddenField ID="hAdministratorsRoleId" runat="server" />
<asp:HiddenField ID="hBackendRoleProviderName" runat="server" />
<asp:HiddenField ID="hBackendRelatedRoleIds" runat="server" />
 
<script type="text/javascript">
    var userFormBinder;
    var closeWindowOnSave;
    var dialogDirty;
 
    var msgControlLoaded;
    var messageControl;
    var adminRoleCheckBox = null;
    var backendRelatedRoleIds = null;
    var roleCheckboxesInfo = null;
 
 
    $("body").addClass("sfFormDialog");
 
    /* ********************************* public methods ********************************* */
 
    Sys.Application.add_load(InitializeDialog);
 
    function InitializeDialog()
        dialogDirty = false;
        userFormBinder = $find('<%= userFormBinder.ClientID %>');
        messageControl = $find('<%= messageControl.ClientID %>');
        var clientLableControl = $find('<%= clientLabelManager.ClientID %>');
        var mpl = $('#<%= membershipProviderList.ClientID %>');
        var defaultProvider = "Default";
        if (mpl != undefined && $('#<%= membershipProviderList.ClientID %>').val() != undefined)
            defaultProvider = $('#<%= membershipProviderList.ClientID %>').val();
            var profilesDataControl = $find("<%= profilesData.ClientID %>");
            mpl.change(function ()
                var val = $(this).val();
                profilesDataControl.refreshForMembershipProvider(val);
            );
            profilesDataControl.refreshForMembershipProvider(defaultProvider);
        
        var label = clientLableControl.getLabel("", defaultProvider);
        $('#PasswordExample').html(label);
 
        userFormBinder.AddValidationRule('UserName', 'required', clientLableControl.getLabel('ErrorMessages', 'CreateUserWizardDefaultUserNameRequiredErrorMessage'));
        userFormBinder.AddValidationRule('Password', 'required', clientLableControl.getLabel('ErrorMessages', 'CreateUserWizardDefaultPasswordRequiredErrorMessage'));
        userFormBinder.AddValidationRule('Email', 'required', clientLableControl.getLabel('ErrorMessages', 'CreateUserWizardDefaultEmailRegularExpressionErrorMessage'));
        userFormBinder.AddValidationRule('Email', 'email', clientLableControl.getLabel('ErrorMessages', 'CreateUserWizardDefaultEmailRegularExpressionErrorMessage'));
        userFormBinder.AddValidationRule('ConfirmPassword', 'required', clientLableControl.getLabel('ErrorMessages', 'CreateUserWizardDefaultConfirmPasswordRequiredErrorMessage'));
        userFormBinder.AddValidationRule('ConfirmPassword', 'equalTo', clientLableControl.getLabel('ErrorMessages', 'CreateUserWizardDefaultConfirmPasswordCompareErrorMessage'), 'Password');
 
        var hCheckBoxesDetails = $get('<%= hCheckBoxesDetails.ClientID %>');
        backendRelatedRoleIds = Sys.Serialization.JavaScriptSerializer.deserialize($get('<%= hBackendRelatedRoleIds.ClientID %>').value);
        roleCheckboxesInfo = Sys.Serialization.JavaScriptSerializer.deserialize(hCheckBoxesDetails.value);
 
        setCheckBoxes();
        BindUserForm();
    
 
    function setCheckBoxes()
        var chkUserIsBackendUser = $get('<%= chkUserIsBackendUser.ClientID %>');
        var hAdministratorsRoleId = $get("<%= hAdministratorsRoleId.ClientID %>");
        chkUserIsBackendUser.checked = true;
 
        for (var i = 0; i < roleCheckboxesInfo.length; i++)
            var cBox = $get(roleCheckboxesInfo[i].ClientId);
            var label = $get(roleCheckboxesInfo[i].LabelClientId);
            if ((cBox != null) && (label != null))
                setLabelText(label, roleCheckboxesInfo[i].Text);
                cBox.value = roleCheckboxesInfo[i].Value;
                cBox.setAttribute("name", "roles");
                if (backendRelatedRoleIds.indexOf(roleCheckboxesInfo[i].Value.split("~")[0]) > -1)
                    $addHandler(cBox, "click", setBackendByAdminCheckBox);
                    adminRoleCheckBox = cBox;
                
            
        
        setBackendByAdminCheckBox();
    
 
    function setBackendByAdminCheckBox(e)
        var chkUserIsBackendUser = $get('<%= chkUserIsBackendUser.ClientID %>');
        var checkBackendToo = false;
        for (var i = 0; i < roleCheckboxesInfo.length; i++)
            var cBox = $get(roleCheckboxesInfo[i].ClientId);
            if ((backendRelatedRoleIds.indexOf(roleCheckboxesInfo[i].Value.split("~")[0]) > -1) && (cBox.checked))
                checkBackendToo = true;
            
        
        if (checkBackendToo)
            chkUserIsBackendUser.checked = true;
            chkUserIsBackendUser.disabled = true;
        
        else
            chkUserIsBackendUser.disabled = false;
        
    
 
    function setLabelText(LabelElement, newText)
        if (typeof LabelElement.textContent != "undefined")
            LabelElement.textContent = newText;
 
        if (typeof LabelElement.innerText != "undefined")
            LabelElement.innerText = newText;
    
 
    function SetForm(providerName)
        messageControl.hide();
    
 
    /* ********************************* user form binder ********************************* */
 
    function BindUserForm()
        if (msgControlLoaded != null && msgControlLoaded !== null)
            msgControlLoaded.hide();
        
 
        userFormBinder.get_globalDataKeys()["Id"] = userFormBinder.GetEmptyGuid();
        userFormBinder.New();
    
 
    function messageControlLoaded(sender, args)
        msgControlLoaded = sender;
    
 
    function errorHandler(sender, args)
        var errorDetail = args.get_error().Detail;
        msgControlLoaded.showNegativeMessage(errorDetail);
    
 
    function onDataBound()
        var question = document.getElementById('passwordanswersquestion');
        var answer = document.getElementById('passwordanswersanswer');
        question.style.display = 'block';
        answer.style.display = 'block';
 
 
        //Load profile data
        var dataItem = ProfileData: '<%= ((Telerik.Sitefinity.Security.Web.UI.Principals.UserNewDialog)this.Parent.Parent).NewUserProfileJson %>' ;
        var profilesDataControl = $find("<%= profilesData.ClientID %>");
        profilesDataControl.set_dataItem(dataItem);
 
        //userFormBinder.AddValidationRule('PasswordQuestion', 'required', clientLableControl.getLabel('ErrorMessages', 'CreateUserWizardDefaultQuestionRequiredErrorMessage'));
        //userFormBinder.AddValidationRule('PasswordAnswer', 'required', clientLableControl.getLabel('ErrorMessages', 'CreateUserWizardDefaultAnswerRequiredErrorMessage'));
    
 
    /* ********************************* methods ********************************* */
 
    function SaveChanges(closeWindow)
        var profilesDataControl = $find("<%= profilesData.ClientID %>");
        if (userFormBinder.IsValid())
            if (profilesDataControl.validate() == true)
                closeWindowOnSave = closeWindow;
 
                var providerName = $('#<%= membershipProviderList.ClientID %>').val();
 
 
                var userObject = GetUserObject();
                var clientManager = new Telerik.Sitefinity.Data.ClientManager();
                var serviceUrl = $('#' + '<%= usersServiceUrl.ClientID %>').val() + '/create/';
                var urlParams = [];
                urlParams['provider'] = providerName;
                var keys = [userFormBinder.GetEmptyGuid()];
 
                clientManager.InvokePut(serviceUrl, urlParams, keys, userObject, SaveUser_Success, SaveUser_Failure);
            
         else
            //Invoke so that validation messages are displayed
            profilesDataControl.validate();
        
    
 
    function GetUserObject()
        var chkUserIsBackendUser = $get('<%= chkUserIsBackendUser.ClientID %>');
        var hBackendUsersRoleId = $get("<%= hBackendUsersRoleId.ClientID %>");
        var hBackendRoleProviderName = $get("<%= hBackendRoleProviderName.ClientID %>");
        // note that binders automatically assign item index to all id attributes. Since the user form
        // binder has only one item, we can get the reference to the field by simply adding 0 - the
        // first index
        var formIndex = 0;
        var usernameField = $get('UserName' + formIndex);
        var passwordField = $get('Password' + formIndex);
        var emailField = $get('Email' + formIndex);
        var confirmPasswordField = $get('ConfirmPassword' + formIndex);
        var passwordQuestionField = $get('PasswordQuestion' + formIndex);
        var passwordAnswerField = $get('PasswordAnswer' + formIndex);
        var commentField = $get('Comment' + formIndex);
 
        var roles = [];
        var backendRoleToo = chkUserIsBackendUser.checked;
        $('input[name="roles"]:checked').each(function (i)
            var vals = $(this).val().split('~');
            roles[i] = 'RoleId': vals[0], 'ProviderName': vals[1] ;
            if (backendRelatedRoleIds.indexOf(vals[0]) > -1)
                backendRoleToo = true;
        );
        if ((chkUserIsBackendUser.checked) && (backendRoleToo))
            roles[roles.length] = 'RoleId': hBackendUsersRoleId.value, 'ProviderName': hBackendRoleProviderName.value ;
        
 
        //Get profile data
        var profilesDataControl = $find("<%= profilesData.ClientID %>");
        profilesDataControl.updateDataItem();
        var dataItem = profilesDataControl.get_dataItem();
 
        var userInfo =
            'UserName': usernameField.value,
            'Password': passwordField.value,
            'Email': emailField.value,
            'PasswordQuestion': passwordQuestionField.value,
            'PasswordAnswer': passwordAnswerField.value,
            'Comment': commentField.value,
            'IsApproved': true,
            'RolesOfUser': roles,
            'ProfileData': dataItem.ProfileData
        ;
 
        return userInfo;
    
 
    function SaveUser_Success(result)
        alert("I am an alert box!");
        if (closeWindowOnSave)
            ClearForm();
            CloseDialogAndRebind();
         else
            var msgText = $get('<%= newUserCreatedMessage.ClientID %>').value;
            messageControl.showPositiveMessage(msgText);
            dialogDirty = true;
            ClearForm();
        
    
 
    function SaveUser_Failure(result)
        messageControl.showNegativeMessage(result.Detail);
    
 
    function ClearForm()
        var chkUserIsBackendUser = $get('<%= chkUserIsBackendUser.ClientID %>');
        var formIndex = 0;
        var usernameField = $get('UserName' + formIndex);
        var passwordField = $get('Password' + formIndex);
        var emailField = $get('Email' + formIndex);
        var confirmPasswordField = $get('ConfirmPassword' + formIndex);
        var passwordQuestionField = $get('PasswordQuestion' + formIndex);
        var passwordAnswerField = $get('PasswordAnswer' + formIndex);
        var commentField = $get('Comment' + formIndex);
 
        usernameField.value = '';
        passwordField.value = '';
        emailField.value = '';
        confirmPasswordField.value = '';
        passwordQuestionField.value = '';
        passwordAnswerField.value = '';
        commentField.value = '';
 
        var profilesDataControl = $find("<%= profilesData.ClientID %>");
        profilesDataControl.reset();
 
        $('input[name="roles"]').each(function (i)
            $(this).removeAttr('checked');
        );
        chkUserIsBackendUser.checked = true;
        chkUserIsBackendUser.disabled = false;
        window.scrollTo(0, 0);
    
 
    /* ********************************* dialog ********************************* */
 
    function CloseDialog()
 
        userFormBinder = $find('<%= userFormBinder.ClientID %>');
        //reset validation notifications
        userFormBinder.ResetFormValidation();
        //clear the form
        ClearForm();
 
        if (dialogDirty)
            CloseDialogAndRebind();
         else
            GetRadWindow().close();
        
    
 
    function CloseDialogAndRebind()
        GetRadWindow().close('rebind');
    
 
    function GetRadWindow()
        var oWindow = null;
        if (window.radWindow)
            oWindow = window.radWindow;
        else if (window.frameElement.radWindow)
            oWindow = window.frameElement.radWindow;
        return oWindow;
    
 
</script>

and to use this template go to Administration->Settings->Advanced->Controls->ViewMap-> clcik create new button and enter:
Host: Telerik.Sitefinity.Security.Web.UI.Principals.UserNewDialog
layoutTemplatePath: ~/MyTemplte.ascx (relative path to your template file)
restart the application when this is saved.

In the template file I have added some text(to distinguish it from the default one) and alert when user is created.

Regards,
Stanislav Velikov
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 23-Jan-2012 00:00

Knowing how to override the template is helpful, but we're looking for a way to execute server-side code when a user is created, not javascript. Is there any way to actually inherit from this control and replace it in the backend?

If there's no way to do this, it's looking to me like there really may be no way of reacting to user create/delete/modify actions in Sitefinity without having to create our own Membership Provider.

Posted by Community Admin on 26-Jan-2012 00:00

Hi,

Unfortunately making use of the server side code for the user template is not possible. We don`t have exposed a setting where to make use of this as there is such for content like news, blogs... . Users are not content and their implementation is different. I have logged this as feature request, here is the request in PITS
What I can offer as a workaround is to use the .ascx template and at the begging add

<script runat="server"type="text/C#">
    ...
</script>
Kind regards,
Stanislav Velikov
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 30-Jan-2012 00:00

Thanks for your reply
,
In truth, from a feature-request standpoint we're not looking to accomplish this-- it was a workaround for a different goal. What we really wanted to do was to be able to globally respond to actions taken on user accounts, regardless of whether it took place in the frontend or backend. Ideally this would involve a global event handler.of some sort.

Our solution ended up being to override the OpenAccessMembershipProvider and overide methods such as CreateUser.

Posted by Community Admin on 14-Feb-2012 00:00

On a similar note, I'm looking to execute special code whenever a _page_ is created or deleted.  Is there an API I could tap into to?

This thread is closed