/** * Login POST verification (authentication) */ public function access() { $pass = F::request()->data->password; # captcha if (!empty(F::get('config')['recaptcha']['public'])) { $captcha = F::request()->data['g-recaptcha-response']; if (!Verif::okCaptcha($captcha)) { $_SESSION['flashbag'] = '<div class="alert alert-danger">Wrong security captcha.</div>'; $this->index(); exit; } } # password if (Verif::okPassword($pass)) { $_SESSION['admin'] = 1; $_SESSION['flashbag'] = ' <div class="alert alert-success alert-dismissible"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> You are now logged in. </div>'; F::redirect('/'); } else { $_SESSION['flashbag'] = '<div class="alert alert-danger">Wrong password.</div>'; } $this->index(); }
/** * Password validation process */ public function save_pass() { $actual_password = F::request()->data->apassword; $pass = F::request()->data->password; $pass2 = F::request()->data->password2; if (Verif::okPassword($actual_password)) { if ($pass === $pass2) { if (!empty($pass)) { if (Action::savePassword($pass)) { $_SESSION['flashbag'] = ' <div class="alert alert-success alert-dismissible"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> Your new password has been saved. </div>'; F::redirect('/settings'); exit; } else { $_SESSION['flashbag'] = '<div class="alert alert-danger">An error occured. Please verify that the app/ and src/ folder are writable.</div>'; } } else { $_SESSION['flashbag'] = '<div class="alert alert-warning">No password ? Are you serious ? Put at least some letters.</div>'; } } else { $_SESSION['flashbag'] = '<div class="alert alert-danger">You must enter the same password twice.</div>'; } } else { $_SESSION['flashbag'] = '<div class="alert alert-danger">Your actual password is wrong.</div>'; } $this->password(); }