本文整理汇总了PHP中Authentication::getError方法的典型用法代码示例。如果您正苦于以下问题:PHP Authentication::getError方法的具体用法?PHP Authentication::getError怎么用?PHP Authentication::getError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authentication
的用法示例。
在下文中一共展示了Authentication::getError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catch
$flash = $app->view()->getData('flash');
$flash['error'] = "Activation code expired, please try the forgotton password link again";
$app->redirect("/login");
}
} catch (ResourceNotFoundException $e) {
// return 404 server error
$app->response()->status(404);
} catch (Exception $e) {
$app->response()->status(400);
$app->response()->header('X-Status-Reason', $e->getMessage());
}
});
$app->post("/forgotpassword", function () use($app) {
$email = $app->request()->post('email');
if (trim($email) == false || preg_match("/^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+\$/", $email) === 0 || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
$app->flash('error', "Please enter in a valid email.<br />");
$app->redirect('/forgotpassword');
}
//run the forgotten password method to email an activation code to the user
$auth = new Authentication($email);
if ($auth->fogottenPassword()) {
//if there were no errors
$app->redirect("/success");
} else {
$app->flash('error', $auth->getError());
$app->redirect('/forgotpassword');
}
});
$app->get("/success", function () use($app) {
$app->render("Authentication/Success.php");
});
示例2: switch
}
if (is_null($email)) {
$error[] = "Email";
$e_email = true;
}
if (count($error) > 0) {
$loadfile = "login/login_error.tpl";
} else {
$auth->setEmail($email);
$auth->setUsername($username);
$auth->setPassword($password);
if ($auth->Authenticate()) {
$loadfile = "login/login_successful.tpl";
$redirect = "/#1";
} else {
$loadfile = "login/login_{$auth->getError()}.tpl";
switch ($auth->getError()) {
case "email":
$e_email = true;
break;
case "username":
$e_username = true;
break;
case "password":
$e_password = true;
break;
}
}
}
} else {
$loadfile = "login/login_form.tpl";