Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<section class="wrapper">
<div class="row">
        <div class="col-lg-12">
                <h3 class="page-header"><i class="icon_document_alt"></i>RESET PASSWORD</h3>
                <ol class="breadcrumb">
                        <li><i class="fa fa-home"></i><a href="${rc.contextPath}/dashboard">Home</a></li>
                        <li><i class="icon_document_alt"></i>Reset Password (Non-Prod)</li>
                </ol>
        </div>
</div>
<div class="container">
        <div class="row">
                <div class="col-lg-4">
                        <label>Reset For</label>
                        <div class="form-group">
                                <select class="form-control" id="resetType">
                                        <option value="AUTH_USER">Auth User (Employee)</option>
                                        <option value="PARTNER">Partner</option>
                                </select>
                        </div>

                        <div id="authUserBlock">
                                <label>Email or Mobile</label>
                                <div class="form-group">
                                        <input type="text" class="form-control" placeholder="Employee email or mobile" id="identifier" autocomplete="off">
                                </div>
                        </div>

                        <div id="partnerBlock" style="display:none;">
                                <label>Partner Name</label>
                                <div class="form-group">
                                        <input type="text" class="typeahead form-control" placeholder="Search Partner" id="typeaheadpartner" name="partner" data-provide="typeahead" autocomplete="off">
                                        <input type="hidden" id="retailerId" value="0">
                                        <small id="selectedPartnerLabel" style="color:#22c55e;"></small>
                                </div>
                        </div>

                        <label>New Password</label>
                        <div class="form-group pass_show">
                                <input type="password" class="form-control" placeholder="New Password" id="newPassword">
                        </div>
                        <label>Confirm Password</label>
                        <div class="form-group pass_show">
                                <input type="password" class="form-control" placeholder="Confirm Password" id="confirmPassword">
                        </div>
                        <div class="form-group">
                                <input type="button" class="btn btn-primary reset-password-override" value="Reset Password">
                        </div>
                </div>
        </div>
</div>
</section>

<script type="text/javascript">
        $(function () {
                $('#resetType').off('change.resetpwd').on('change.resetpwd', function () {
                        if ($(this).val() === 'PARTNER') {
                                $('#partnerBlock').show();
                                $('#authUserBlock').hide();
                        } else {
                                $('#partnerBlock').hide();
                                $('#authUserBlock').show();
                        }
                });

                getPartnerAheadOptions($('#typeaheadpartner'), function (selectedPartner) {
                        $('#retailerId').val(selectedPartner.partnerId);
                        $('#selectedPartnerLabel').text('Selected: ' + selectedPartner.displayName + ' (id ' + selectedPartner.partnerId + ')');
                });

                $(document).off('click.resetpwd', '.reset-password-override').on('click.resetpwd', '.reset-password-override', function () {
                        var type = $('#resetType').val();
                        var newPassword = $('#newPassword').val();
                        var confirmPassword = $('#confirmPassword').val();

                        if (!newPassword) {
                                alert('Please enter a new password');
                                return;
                        }
                        if (newPassword !== confirmPassword) {
                                alert('Passwords do not match');
                                return;
                        }

                        var params = {"type": type, "newPassword": newPassword};
                        if (type === 'PARTNER') {
                                var retailerId = $('#retailerId').val();
                                if (!retailerId || retailerId === '0') {
                                        alert('Please select a partner from the suggestions');
                                        return;
                                }
                                params.retailerId = retailerId;
                        } else {
                                var identifier = $('#identifier').val();
                                if (!identifier) {
                                        alert('Please enter an email or mobile');
                                        return;
                                }
                                params.identifier = identifier;
                        }

                        doPostAjaxRequestWithParamsHandler(context + "/resetPasswordOverride", params, function (response) {
                                alert('Password reset successfully');
                                $('#newPassword').val('');
                                $('#confirmPassword').val('');
                        });
                });
        });
</script>