Disable 'Forgot your password' feature

Posted by Community Admin on 03-Aug-2018 13:03

Disable 'Forgot your password' feature

All Replies

Posted by Community Admin on 05-Oct-2011 00:00

Hi

Is it possible to disable requesting a new password using the ‘Forgot your password’ feature for certain users?

Thanks

Regards

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

Hi John,

In the login page permissions are still not present since users aren`t logged to apply the permission. So filtering of users should be applied based on a preferred logic. It can be based on user IP, browser etc.
To do this map the template for the login form. Go to Administration->Settings->Advanced->Controls->ViewMap->create new.
Host:Telerik.Sitefinity.Security.Web.UI.LoginForm
Template: Put the relative path to your template file (~/Templates/LoginCustom.ascx)
The template markup is.

<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI"
    TagPrefix="sitefinity" %>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.Fields"
    TagPrefix="sffields" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<%@ Control Language="C#" %>
 
 
<script type="text/C#" runat="server">
    protected void Page_Load()
    
       //Custom logic here
       
</script>
 
 
<sitefinity:ResourceLinks ID="resourcesLinks" runat="server">
    <sitefinity:ResourceFile JavaScriptLibrary="JQuery">
    </sitefinity:ResourceFile>
</sitefinity:ResourceLinks>
 
<sitefinity:ClientLabelManager id="clientLabelManager" runat="server">
    <Labels>
        <sitefinity:ClientLabel ClassId="Labels" Key="SelfLogoutUserConfirm" runat="server" />
        <sitefinity:ClientLabel ClassId="Labels" Key="UserNotSelected" runat="server" />
        <sitefinity:ClientLabel ClassId="Labels" Key="LogoutUserConfirm" runat="server" />
    </Labels>
</sitefinity:ClientLabelManager>
 
<sffields:FormManager runat="server" id="formManager" />
<asp:Panel ID="loginPanel" runat="server">
    <div class="sfForm">
        <div class="sfFormIn">
            <div class="sfLoginShadowTopRight">
            </div>
            <div class="sfLoginShadowBottomLeft">
            </div>
            <h2>
                <asp:Literal ID="LoginTitle" Text="<%$ Resources:Labels, LoginToManage %>" runat="server" />
            </h2>
            <asp:Label runat="server" ID="FailureText" EnableViewState="False" Visible="false"
                CssClass="sfFailure" />        
            <ol>
                <li id="ProvidersHolder" runat="server">
                    <asp:Label ID="ProvidersLabel" Text="<%$ Resources:Labels, Provider %>" AssociatedControlID="ProvidersList"
                        runat="server" CssClass="sfTxtLbl" />
                    <asp:DropDownList ID="ProvidersList" AutoPostBack="false" AccessKey="l" runat="server" />
                </li>
                <li>
                    <asp:Label ID="UserNameLabel" Text="<%$ Resources:Labels, Username %>" AssociatedControlID="UserName"
                        runat="server" CssClass="sfTxtLbl" />
                    <asp:TextBox ID="UserName" AccessKey="u" runat="server" CssClass="sfTxt" />
                    <asp:RequiredFieldValidator ID="UserNameRequired" Display="Dynamic" ControlToValidate="UserName"
                        ValidationGroup="LoginBox" ErrorMessage="<%$ Resources:Labels, UsernameCannotBeEmpty %>"
                        CssClass="sfValidator" runat="server">
                <strong><asp:Literal ID="UserNameRequiredLiteral" runat="server" Text="<%$ Resources:Labels, UsernameCannotBeEmpty %>" /></strong>
                    </asp:RequiredFieldValidator>
                </li>
                <li>
                    <asp:Label ID="PasswordLabel" Text="<%$ Resources:Labels, Password %>" AssociatedControlID="Password"
                        runat="server" CssClass="sfTxtLbl" />
                    <asp:TextBox ID="Password" TextMode="Password" AccessKey="p" runat="server" CssClass="sfTxt" />
                    <asp:RequiredFieldValidator ID="PasswordRequired" Display="Dynamic" ControlToValidate="Password"
                        ValidationGroup="LoginBox" ErrorMessage="<%$ Resources:Labels, PasswordCannotBeEmpty %>"
                        CssClass="sfValidator" runat="server">
                <strong><asp:Literal ID="PasswordRequiredLiteral" runat="server" Text="<%$ Resources:Labels, PasswordCannotBeEmpty %>" /></strong>
                    </asp:RequiredFieldValidator>
                </li>
                <li class="sfCheckBoxWrapper">
                    <asp:CheckBox runat="server" ID="RememberMe" />
                    <asp:Label ID="RememberMeTextLabel" Text="<%$ Resources:Labels, RememberMe %>" AssociatedControlID="RememberMe"
                        runat="server" />
                </li>
            </ol>
            <p class="sfSubmitBtn sfMainFormBtns">
                <asp:LinkButton ID="LoginButton" CommandName="Login" CssClass="sfLinkBtn sfSave"
                    ValidationGroup="LoginBox" runat="server">
                    <strong class="sfLinkBtnIn">
                        <asp:Literal ID="LoginButtonLiteral" runat="server" Text="<%$ Resources:Labels, LoginCaps %>"></asp:Literal>
                    </strong>
                </asp:LinkButton>
                <!-- do not remove this button. It is used for the default form submit (pressing enter) -->
                <div style="display: none;">
                    <asp:Button ID="hiddenSubmitButton" runat="server" CommandName="Login" ValidationGroup="LoginBox" />
                </div>
            </p>       
        </div>
    </div>
</asp:Panel>
<asp:Panel ID="userListPanel" runat="server" Visible="false">
    <div class="sfForm">
        <div class="sfFormIn">
            <div class="sfLoginShadowTopRight"></div>
            <div class="sfLoginShadowBottomLeft"></div>
            <h2><asp:Literal ID="UsersListPanelLoginTitle" Text="<%$ Resources:Labels, LoginToManage %>" runat="server" /></h2>
            <p class="sfNeutral"><asp:Literal ID="userLimitLabel" runat="server" Text="<%$ Resources:Labels, UserLimitLabel%>" /></p>
            <sffields:ChoiceField runat="server" id="userListChoice" RenderChoicesAs="RadioButtons"
                DisplayMode="Write" />
            <p class="sfSubmitBtn sfMainFormBtns">
                <asp:LinkButton ID="logoutButton" runat="server" OnClientClick="return AlertLogOut();" CssClass="sfLinkBtn sfPrimary">
                    <strong class="sfLinkBtnIn">
                        <asp:Literal ID="LogoutButtonLiteral" runat="server" Text="<%$ Resources:Labels, LogoutButtonText%>"></asp:Literal>
                    </strong>
                </asp:LinkButton>
            </p>
        </div>
    </div>
</asp:Panel>
 
<asp:Panel ID="selfLogoffPanel" runat="server" Visible="false">
    <div class="sfForm">
        <div class="sfFormIn">
            <div class="sfLoginShadowTopRight"></div>
            <div class="sfLoginShadowBottomLeft"></div>
            <h2><asp:Literal ID="SelfLogoffPanelLoginTitle" Text="<%$ Resources:Labels, LoginToManage %>" runat="server" /></h2>
            <p class="sfNeutral"><asp:Literal ID="selfLogoffLabel" runat="server" Text="<%$ Resources:Labels, SelfLogoffLabel%>" /></p>
            <p class="sfSubmitBtn sfMainFormBtns">
                <asp:LinkButton ID="selfLogoutButton" runat="server" OnClientClick="return AlertSelfLogOut();" CssClass="sfLinkBtn sfPrimary">
                    <strong class="sfLinkBtnIn">
                        <asp:Literal ID="LogoutOtherUserAndEnterLiteral" runat="server" Text="<%$ Resources:Labels, SelftLogoutButtonText%>"></asp:Literal>
                    </strong>
                </asp:LinkButton>
                <asp:LinkButton ID="selfLogoutCancelButton" runat="server" Text="<%$ Resources:Labels, Cancel%>" CssClass="sfCancel" />
            </p>
        </div>
    </div>
</asp:Panel>
 
<asp:Panel ID="denyLogonPanel" runat="server" Visible="false">
    <div class="sfForm">
        <div class="sfFormIn">
            <div class="sfLoginShadowTopRight"></div>
            <div class="sfLoginShadowBottomLeft"></div>
                <h2><asp:Literal ID="DenyLogonPanelLoginTitle" Text="<%$ Resources:Labels, LoginToManage %>" runat="server" /></h2>
                <p class="sfNeutral"><asp:Literal ID="denyLogonMesage" runat="server" Text="<%$ Resources:Labels, DenyLogonMesage%>" /></p>
                <p><asp:Literal ID="loginRetryMessage" runat="server" Text="<%$ Resources:Labels, LoginRetryMessage%>" /></p>
        </div>
    </div>
</asp:Panel>
 
<asp:PlaceHolder ID="loginLinksHolder" runat="server">
    <div class="sfLoginHelp">
        <asp:Literal ID="HelpTitleLiteral" runat="server" Text="<%$ Resources:Labels, Help %>" />:
        <a id="PasswordRecoveryLink" href="~/Sitefinity/Login/PasswordRecovery" runat="server" onclick="toggleSmtpErrorMessage();">
            <asp:Literal ID="PasswordRecoveryTextLiteral" runat="server" Text="<%$ Resources:Labels, ForgotYourPassword %>" />
        </a>
        <a id="ChangePasswordLink" href="~/Sitefinity/Login/ChangePassword" runat="server" onclick="toggleSmtpErrorMessage();">
            <asp:Literal ID="ChangePasswordTextLiteral" runat="server" Text="<%$ Resources:Labels, ChangePassword %>" />
        </a>
        <a id="CreateUserLink" href="~/Sitefinity/Login/Register" runat="server">
            <asp:Literal ID="RegisterUserTextLiteral" runat="server" Text="<%$ Resources:Labels, Register %>" />
        </a>
        <a id="HelpLink" href="~/Sitefinity/Help/UsersAndRoles/LoggingIn" runat="server">
            <asp:Literal ID="HelpLinkLiteral" runat="server" Text="<%$ Resources:Labels, Help %>" />
        </a>       
    </div>
</asp:PlaceHolder>
 
<div id="smtpNotSetContainer" class="sfNeutral sfDetailedInfo" style="display:none;">  
    <h3>
        <asp:Literal ID="ErrorMessageNoSmtpConfigLiteral" runat="server" Text="<%$ Resources:ErrorMessages, TheSystemHasNotBeenConfiguredToSendEmails %>" />
    </h3>
    <ul>
        <li><asp:Literal ID="ErrorMessageContactAdminToResetYourPasswordLiteral" runat="server" Text="<%$ Resources:ErrorMessages, ContactAnAdministratorToResetYourPasswordManually %>" /></li>
        <li>
            <asp:Literal ID="ErrorOrAskAnAdministratorToConfigureTheSystemLiteral" runat="server" Text="<%$ Resources:ErrorMessages, OrAskAnAdministratorToConfigureThSystem %>" />
            <a href="javascript:void(0)" onclick="toggleVisibility('smtpNotSetSolution')">
                <asp:Literal ID="ErrorMessageSmtpDetailsTitle" runat="server" Text="<%$ Resources:ErrorMessages, Details %>" />
            </a>
        </li>
    </ul>
    <div id="smtpNotSetSolution" class="sfDetailedHowTo" style="display: none; ">
        <p><asp:Literal ID="ErrorMessageSmtpSettingsNotSetLiteral" runat="server" Text="<%$ Resources:ErrorMessages, SmtpSettingsAreNotSet %>" /></p>
        <h3><asp:Literal ID="ErrorMessageHowToSetSmtpLiteral" runat="server" Text="<%$ Resources:ErrorMessages, HowToSetSMTP %>" /></h3>
        <ol>
            <li><asp:Literal ID="Literal20" runat="server" Text="<%$ Resources:ErrorMessages, GoToSettingsConfiguration %>" /></li>
            <li><asp:Literal ID="Literal21" runat="server" Text="<%$ Resources:ErrorMessages, SelectSystemSMTPSettings %>" /></li>
        </ol>
    </div>
</div>
 
<div id="smtpPermissionDeniedContainer" class="sfNeutral sfDetailedInfo" style="display:none;">
    <h3>
        <asp:Literal ID="ErrorMessageTheSysIsNotPermittedToSendEmailsLiteral" runat="server" Text="<%$ Resources:ErrorMessages, TheSystemHasIsNotPermittedToSendEmails %>" />
    </h3>
    <ul>
        <li><asp:Literal ID="ErrorMessageContactAdminToResetYourPasswordSmtpLiteral" runat="server" Text="<%$ Resources:ErrorMessages, ContactAnAdministratorToResetYourPasswordManually %>" /></li>
        <li>
            <asp:Literal ID="ErrorOrAskAnAdministratorToConfigureTheSystemSmtpLiteral" runat="server" Text="<%$ Resources:ErrorMessages, OrAskAnAdministratorToConfigureThSystem %>" />
            <a href="javascript:void(0)" onclick="toggleVisibility('smtpPermissionsDeniedDetails')">
                <asp:Literal ID="ErrorMessageSmtpPermissionDeniedDetailsTitle" runat="server" Text="<%$ Resources:ErrorMessages, Details %>" />
            </a>
        </li>
    </ul>
    <div id="smtpPermissionsDeniedDetails" class="sfDetailedHowTo" style="display: none; ">
        <p><asp:Literal ID="SmtpPermissionErrorMessage" runat="server" /></p>       
    </div>
</div>
Test Test
<asp:HiddenField id="logoutUser" runat="server" value="" />
<asp:HiddenField id="loginTicket" runat="server" value="" />
<asp:HiddenField id="mode" runat="server" value="" />
<asp:HiddenField id="smtpSettingsAreSet" runat="server" value="" />
<asp:HiddenField id="smtpPermissionDenied" runat="server" value="" />
 
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
 
    var userChoices;
    var smtpSettingsAreSet;
    var smtpPermissionDenied;
 
    function pageLoad()
        userChoices = $find("<%= userListChoice.ClientID %>");
        smtpSettingsAreSet = getBooleanHiddenField("<%= smtpSettingsAreSet.ClientID %>");
        smtpPermissionDenied = getBooleanHiddenField("<%= smtpPermissionDenied.ClientID %>");
    
 
    function getBooleanHiddenField(id)
        var field = $get(id);
 
        if (field !== null && field.value)
            return Boolean.parse(field.value);
        
 
        return false;
    
 
    function toggleVisibility()
        var elem = arguments[0] ? document.getElementById(arguments[0]) : this;
        if (elem.style.display == "block")
            elem.style.display = "none";
        
        else
            elem.style.display = "block";
        
    
 
    function toggleSmtpErrorMessage()
        if (!smtpSettingsAreSet)
            toggleVisibility('smtpNotSetContainer');
         else if (smtpPermissionDenied)
            toggleVisibility('smtpPermissionDeniedContainer');
        
    
 
    function AlertSelfLogOut()
        var clientLabelManager = $find('<%= clientLabelManager.ClientID %>');
        var result = confirm(clientLabelManager.getLabel('Labels', 'SelfLogoutUserConfirm'));
        return result;
    
 
    function AlertLogOut()
        var clientLabelManager = $find('<%= clientLabelManager.ClientID %>');
        var value = userChoices.get_value();
 
        if (value == null || value.length == 0)
            alert(clientLabelManager.getLabel('Labels', 'UserNotSelected'));
            return false;
        
 
        var selectedItemId = userChoices.get_value(); // selectedItem[0].id;
        var result = confirm(clientLabelManager.getLabel('Labels', 'LogoutUserConfirm'));
 
        if (result)
            $get('<%= logoutUser.ClientID %>').value = value;
 
        
        return result;
    
 
</script>
</telerik:RadCodeBlock>
Add custom logic that will filter the users based on IP/browser or else. You can hide the forgot your password link trough adding a property display: none to certain class in Css.

To disable the forget password link globally for all users use a modified backend theme. You can download the default backend theme Sitefinity uses from Sitefinity SDK. Modify Login.css like
.sfLoginForm .sfLoginHelp a, .sfLoginForm .sfLoginHelp a:link, .sfLoginForm .sfLoginHelp a:visited, .sfLoginForm .sfLoginHelp a:hover, .sfLoginForm .sfLoginHelp a:active
    display: none;


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

This thread is closed