Viewing File: /usr/local/cpanel/base/webmail/jupiter/mail/change_password.html.tt

[%
    SET CPANEL.CPVAR.dprefix = "../",
        auth_user = ExpVar.expand('$authuser');

    IF (ExpVar.expand('$appname') == "webmail");
        SET auth_user_info = auth_user.split('@');
        IF !FORM.item('email');
            SET FORM.email = auth_user_info.0;
        END;
        IF !FORM.item('domain');
            SET FORM.domain = auth_user_info.1;
        END;
    END;

    # Fetch the required strength
    Api2.pre_exec("PasswdStrength", "get_required_strength");
    SET required_strength_resp = Api2.exec("PasswdStrength", "get_required_strength", {"app"=>"pop"} );
    Api2.post_exec("PasswdStrength", "get_required_strength");

    IF required_strength_resp.size();
        SET required_strength = required_strength_resp.0.strength;
    END;

     SET email = FORM.item('email');
     SET domain = FORM.item('domain');
     SET email_account = email _ "@" _ domain;
%]

[% css_code_block = PROCESS css_block %]
[% js_code_block = PROCESS js_block %]

[% WRAPPER '_assets/master.html.tt'
    app_key = 'change_password'
    page_title = locale.maketext('Password [output,amp] Security')
    page_styles = css_code_block
    page_js = js_code_block
    page_scripts = CPANEL.is_debug_mode_enabled() ?
        [ 'libraries/handlebars/handlebars.js' ] :
        [ 'libraries/handlebars/handlebars.min.js' ]
-%]

<p id="chooseWebmail">
    [% locale.maketext('Enter a new password for this account.') %]
</p>

[%
    SET external_auth_modules = execute("ExternalAuthentication","configured_modules").data;
    SET configured_providers = execute("ExternalAuthentication","get_authn_links").data;
%]

[% IF external_auth_modules.size && external_auth_modules %]
    <div class="body-content">
        <div class="section">
            <h2>
                [% locale.maketext('Change Password') %]
            </h2>
            <div>
                [% PROCESS change_password_form %]
            </div>
        </div>
        <div class="section">
            <h2>
                [% locale.maketext('External Authentication') %]
            </h2>
            <div>
                [% PROCESS manage_external_auth.tmpl %]
           </div>
        </div>
        <div growl></div>
    </div>

    <script type="text/javascript">
        CPANEL.namespace("CPANEL.PAGE");
        CPANEL.PAGE.external_auth_modules = [% external_auth_modules.json(); %];
        CPANEL.PAGE.configured_providers  = [% configured_providers.json(); %];
    </script>
[% ELSE %]
    <div class="body-content">
        [% PROCESS change_password_form %]
    </div>
[% END %]

[%
    USE JSON;
    SET requirejs_url_base = '/webmail/' _ CPANEL.CPDATA.RS;
%]

<script>
    var PAGE = window.PAGE || {};
    PAGE = {
        THEME_PATH : [% requirejs_url_base.json() %],
    };
</script>

[% END # WRAPPER END %]

[% BLOCK change_password_form %]
    [% IF email_account == auth_user %]
    <div id="changePasswordNotice">
    </div>
    <section id="changePasswordSection">
        <div class="form-group">
            <label for="txtPassword">[% locale.maketext('New Password') %]</label>
            <div class="row">
                <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    <input type="password" id="txtPassword" class="form-control" />
                </div>
                <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    <span id="txtPassword_error"></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label for="txtPasswordAgain">[% locale.maketext("Confirm New Password") %]</label>
            <div class="row">
                <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    <input type="password" id="txtPasswordAgain" class="form-control" />
                </div>
                <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    <span id="txtPasswordAgain_error"></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label id="lblPasswordStrength">
                [% locale.maketext("Password Strength") %]
                <span id="why_strong_passwords_link" class="glyphicon glyphicon-info-sign"></span>
            </label>
            [% INCLUDE _assets/why_strong_passwords.html.tt %]
            <div class="row">
                <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    <div id="password_strength" class="password_strength"></div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    <input id="create_strong_password" type="button" class="btn btn-default" value="[% locale.maketext("Password Generator") %]" tabindex="-1" />
                </div>
            </div>
        </div>
        <div class="form-group">
            <input type="button" class="btn btn-primary" value="[% locale.maketext('Save') %]" id="btnChangePassword" />
        </div>
    </section>

    <script id="successNotice" type="text/x-handlebars-template">
        <div class="alert alert-success alert-dismissable">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
            <span class="glyphicon glyphicon-ok-sign"></span>
            <div class="alert-message">
                <strong>[% locale.maketext("Success:") %]</strong>
                {{message}}
            </div>
        </div>
    </script>

    <script id="errorNotice" type="text/x-handlebars-template">
        <div class="alert alert-danger">
            <span class="glyphicon glyphicon-remove-sign"></span>
            <div class="alert-message">
                <strong>[% locale.maketext("Error:") %]</strong>
                {{message}}
            </div>
        </div>
    </script>
    [% ELSE %]
        <div class="alert alert-danger">
            <span class="glyphicon glyphicon-remove-sign"></span>
            <div ng-non-bindable class="alert-message">
                <strong>[% locale.maketext("Error:") %]</strong>
                 [% locale.maketext("The system experienced an error when it attempted to save the new password for the following account: [_1].", email_account) %]
            </div>
        </div>
    [% END %]
[% END # change_password_form %]

[% BLOCK css_block %]
    <style>
        .external-auth-icon {
            display: inline-block;
            width: 35px;
            height: 35px;
            margin: 3px 10px 3px 0;
            vertical-align: middle;
            border: 1px solid #FFF;
            background-size: 75% 75%;
            background-position: center;
            background-repeat: no-repeat;
        }

        html[dir="rtl"] .external-auth-icon {
            margin: 3px 0 3px 10px;
        }

        .table .provider-username {
            padding-left: 55px;
        }

        html[dir="rtl"] .table .provider-username {
            padding-right: 55px;
        }

        @media (max-width: 667px) {
            .external-auth-icon {
                width: 25px;
                height: 25px;
            }

            .table .provider-username {
                padding-left: 47px;
            }

            html[dir="rtl"] .table .provider-username {
                padding-right: 47px;
            }
        }
    </style>
[% END # css_block END %]

[% BLOCK js_block %]
    <script type="text/javascript">
    (function(){
        var REQUIRED_PASSWORD_STRENGTH = parseInt('[% required_strength %]', 10) || 5;
        var Handlebars = window.Handlebars;

        var change_password_success_template = Handlebars.compile(DOM.get("successNotice").text.trim());
        var change_password_error_template = Handlebars.compile(DOM.get("errorNotice").text.trim());
        var notice = YAHOO.util.Dom.get("changePasswordNotice");

        function changePassword() {
            // create the API variables
            var password = YAHOO.util.Dom.get("txtPassword").value;

            var callback = {
                success: _success,
                failure: _failure
            };

            CPANEL.api({
                version: 3,
                module: "Email",
                func: "passwd_pop",
                data: {
                    email: [% email.json() %],
                    domain: [% domain.json() %],
                    password: password
                },
                callback: callback
            });


            // callback functions
            function _success(o) {
                var result = o.cpanel_raw;

                if (result.messages) {
                    var successMessage = result.messages.join(" ");
                    notice.innerHTML =  change_password_success_template({
                         message: "[% locale.maketext('You successfully changed your password.') %]" + " " + successMessage
                    });
                } else {
                    notice.innerHTML =  change_password_success_template({
                         message: "[% locale.maketext('You successfully changed your password.') %]"
                    });
                }
                clearForm();
            }

            function _failure(o) {
                var result = o.cpanel_raw,
                    errorContent = "";

                if (result.errors) {
                    errorContent = result.errors.join(" ");
                    notice.innerHTML = change_password_error_template({
                        message: "[% locale.maketext('The system experienced an error when it attempted to save the new password.') %]" + " " + errorContent
                    });
                } else {
                    notice.innerHTML = change_password_error_template({
                        message: "[% locale.maketext('The system experienced an error when it attempted to save the new password.') %]"
                    });
                }
                clearForm();
            }

            function clearForm() {
                YAHOO.util.Dom.get("txtPassword").value = "";
                YAHOO.util.Dom.get("txtPasswordAgain").value = "";
            }

        }

        var init_page = function() {
            var password_validators = CPANEL.password.setup("txtPassword", "txtPasswordAgain", "password_strength", REQUIRED_PASSWORD_STRENGTH, "create_strong_password", "why_strong_passwords_link", "why_strong_passwords_text");

            CPANEL.validate.attach_to_form("btnChangePassword", [password_validators[0], password_validators[1]], changePassword);

            YAHOO.util.Dom.get("txtPassword").focus();
        };
        YAHOO.util.Event.onDOMReady(init_page);
    })()
    </script>
[% END # js_block END %]

[% PROCESS '_assets/cjt2_header_include.tt' %]
Back to Directory File Manager