/** * Check if the credentials match an admin and return the admin id. * * @param string $email * @param string $password * @return integer */ public function match($email, $password) { $ar = new AdminsRepository(); $admin = $ar->getByEmail($email); if (!$admin) { return 0; } if (password_verify($password, $admin->password)) { return $admin->id; } return 0; }
public function postChangePassword($req) { $ar = new AdminsRepository(); $admin = $ar->getById($req->id); $admin->password = password_hash($_POST['password'], PASSWORD_DEFAULT); $result = $admin->save(); if ($result) { $this->service->flash('The password was changed.', 'success'); } else { $this->service->flash('Can\'t change the password.', 'alert'); } return $this->service->back(); }