<?= $this->extend('layouts/smarthome'); ?>
<?= $this->section('menu'); ?>
    <?= $this->include('menu/dashboard_menu') ?>
<?= $this->endSection(); ?>
<?= $this->section('content'); ?>
<div class="container">
<div class="row">
		<div class="col-sm-6 offset-sm-3">

        <div class="card bg-secondary">
            <div class="card-body bg-dark text-white-50">
                <h5 class="card-header">Hallo <?= auth()->user()->username ?>, Passwort ändern</h5>

                <?php if (session('error') !== null) : ?>
                    <div class="alert alert-danger" role="alert"><?= session('error') ?></div>
                <?php elseif (session('errors') !== null) : ?>
                    <div class="alert alert-danger" role="alert">
                        <?php if (is_array(session('errors'))) : ?>
                            <?php foreach (session('errors') as $error) : ?>
                                <?= $error ?>
                                <br>
                            <?php endforeach ?>
                        <?php else : ?>
                            <?= session('errors') ?>
                        <?php endif ?>
                    </div>
                <?php endif ?>

                <?php if (session('message') !== null) : ?>
                    <div class="alert alert-success" role="alert"><?= session('message') ?></div>
                <?php endif ?>

                <form action="changePassword" method="post">
                    <?= csrf_field() ?>

                    <!-- Email -->
                    <div class="mb-2">
                        <input type="email" class="form-control bg-transparent text-light " name="email" inputmode="email" autocomplete="email" placeholder="<?= lang('Auth.email') ?>" value="<?= old('email',$email) ?>" required />
                    </div>
                    <!-- old Password -->
                    <?php if (session('magicLogin') === null) : ?>
                    <div class="mb-2">
                        <input type="password" class="form-control bg-transparent text-light " name="oldpassword" inputmode="text" autocomplete="current-password" placeholder="neues Passwort" required />
                    </div>       
                    <?php endif ?>            
                    <!-- Password -->
                    <div class="mb-2">
                        <input type="password" class="form-control bg-transparent text-light " name="password" inputmode="text" autocomplete="new-password" placeholder="neues Passwort" required />
                    </div>
                    <!-- Password (Again) -->
                    <div class="mb-5">
                        <input type="password" class="form-control bg-transparent text-light " name="password_confirm" inputmode="text" autocomplete="new-password" placeholder="<?= lang('Auth.passwordConfirm') ?>" required />
                    </div>

                    <div class="d-grid col-12 col-md-8 mx-auto m-3">
                        <button type="submit" class="btn btn-primary btn-block">Ändern</button>
                    </div>
                </form>
            </div>
        </div>
    </div>


<?= $this->endSection(); ?>