$password2 = $_POST['password2']; $roles = $_POST['roles']; $type = $_POST['add-type']; unset($_POST['csrf_token']); unset($_POST['action']); unset($_POST['username']); unset($_POST['password']); unset($_POST['password2']); unset($_POST['roles']); unset($_POST['add-type']); $logfiles = $_POST; $errors = array(); if (empty($username)) { $errors['username'] = __('Username is required'); } else { if ($type === 'add' && Sentinel::userExists($username)) { $errors['username'] = sprintf(__('User %s already exists'), '<code>' . $username . '</code>'); } } if ($type === 'edit' && !empty($password) || $type === 'add') { if (mb_strlen($password) < 6) { $errors['password'] = __('Password must contain at least 6 chars'); } if ($password !== $password2) { $errors['password2'] = __('Password confirmation is not the same'); } } if (count($errors) === 0) { if (empty($password)) { $password = null; }
?> "></div></div></div><br><br><input type="submit" class="btn btn-large btn-success" value="<?php _h('Enable authentication'); ?> "></form><?php } ?> </div><div class="tab-pane" id="passwordtab"><?php if (Sentinel::isAuthSet()) { ?> <br><h4><?php _e('Please fill an existing username and a new password'); ?> </h4><?php if (@$_POST['action'] === 'passwordtab') { if (!Sentinel::userExists($_POST['username'])) { echo '<div class="alert alert-danger" role="alert">' . sprintf(__('User %s does not exist!'), '<code>' . $_POST['username'] . '</code>') . '</div>'; } else { if ($_POST['password'] !== $_POST['password2']) { echo '<div class="alert alert-danger" role="alert">' . __('Password confirmation is not the same') . '</div>'; } else { if (mb_strlen($_POST['password']) < 6) { echo '<div class="alert alert-danger" role="alert">' . __('Password must contain at least 6 chars') . '</div>'; } else { Sentinel::setUser($_POST['username'], $_POST['password']); Sentinel::save(); echo '<div class="alert alert-success" role="alert">' . sprintf(__('Password has been updated for user %s!'), '<code>' . $_POST['username'] . '</code>') . '</div>'; } } } }