<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="google" content="notranslate" />
        <meta http-equiv="Content-Language" content="en_US" />
        <title>CFEngine Mission Portal - Change password</title>
        <?php $this->carabiner->display('CFEngine','css'); ?>
    </head>

    <body>
        <div class="login-wrapper">
             <!--[if lte IE 7]><script src="<?php echo get_scriptdir() ?>/ieupgrade/warning.js"></script><script>window.onload=function(){e("<?php echo get_scriptdir() ?>/ieupgrade/")}</script><![endif]-->
                <div id="login">
                    <div class="login-box change-password">

                        <div id="login-form-container" class="margin-top">
                            <p id="default-warning" class="alert alert-warning"><?= htmlspecialchars($explanation) ?></p>
                            <p id="default-logging" style="display: none" class="alert alert-info">Logging in...</p>


                            <div id="formInfoMessage" class="margin-top"><?php if (isset($message) && $message != '') echo htmlspecialchars($message); ?></div>

                            <div id="login-form-container" style="margin-top:40px">
                            <?php echo form_open("auth/change_password/" . $this->uri->segment(3), array('id'=>'change_password','class'=>'form-horizontal')); ?>
                                 <?php

                                    $loggedinusername = isset($username) ? $username : $this->session->userdata('username');

                                  ?>

                                <?php if ($this->session->userdata("defaultadmin")) { ?>
                                <input id="old" type="hidden" name="old" value="admin">
                                <?php } else { ?>
                                <div class="control-group required">
                                    <label class="control-label" for="old">Old password</label>
                                    <div class="controls">
                                        <input id="old" type="password" required name="old" value="<?= htmlspecialchars($old) ?>">
                                        <?php $this->load->view('common/show-password-btn.php'); ?>
                                    </div>
                                </div>
                                <?php } ?>
                                <div class="control-group required">
                                    <label class="control-label" for="new">New password</label>
                                     <div class="controls">
                                        <input id="new" type="password" required name="new" class="invalid" value="<?php echo set_value('new');?>">
                                         <?php $this->load->view('common/show-password-btn.php'); ?>
                                     </div>
                                </div>
                                 <div class="control-group required">
                                    <label class="control-label no-padding no-margin" for="new_confirm">Confirm new password</label>
                                     <div class="controls">
                                        <input id="new_confirm" type="password" required name="new_confirm" value="<?php echo set_value('new_confirm');?>">
                                         <?php $this->load->view('common/show-password-btn.php'); ?>
                                     </div>
                                </div>
                                
                                <?php if ($show2fa) { ?>
                                    <div class="control-group required">
                                        <label class="control-label" for="twoFaCode">Authentication code</label>
                                        <div class="controls">
                                            <input id="twoFaCode" placeholder="xxxxxx" autocomplete="off" maxlength="6" type="text" name="twoFaCode" value="<?= htmlspecialchars($twoFaCode) ?>" />
                                            <div class="margin-top-small margin-bottom">Open your authentication app on your device to retrieve the code.</div>
                                        </div>
                                    </div>
                                <?php } ?>
                                <div class="control-group">
                                    <div class="controls">

                                        <button type="submit" id="save" class="btn btn-large btn-primary float-right margin-left-small">
                                        Save
                                        </button>
                                        <a href="<?php echo site_url('login/logout'); ?>" class="btn btn-large btnCancel float-right" type="button">Cancel</a>
                                    </div>
                                </div>

                            <?php echo form_close();?>
                            </div>
                            <div id="msg"></div>
                         </div>
                    </div>
                </div>
            </div>
        </div>
        <script>
            var minPasswordLength = <?= $minPasswordLength ?>;
            var passwordComplexity = <?= $passwordComplexity ?>;
        </script>
        <?php
            $this->carabiner->display('login');
        ?>
    </body>
</html>
