本文整理汇总了PHP中Authentication::authenticateUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Authentication::authenticateUser方法的具体用法?PHP Authentication::authenticateUser怎么用?PHP Authentication::authenticateUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authentication
的用法示例。
在下文中一共展示了Authentication::authenticateUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trim
<?php
//check if user is already logged in
//check if session_username doesnt already exist and that Log In form has been submitted
if (isset($_POST['login'])) {
if (!empty($_POST['username']) && !empty($_POST['password'])) {
#trim values
$username = trim($_POST['username']);
$password = trim($_POST['password']);
$user = new Authentication();
//authenticate user
if ($user->authenticateUser($db, $username, $password)) {
//check account_status
if (!$user->accountStatus($db, $username)) {
$message = "This Account was deactivated. Contact the System Administrator.";
$smarty->assign('accountMsg', $message);
$content = $smarty->fetch('./logon/tm0.logon.logon_err.tpl.html');
include_once './config/disconnect.inc.php';
} else {
//Register login Username
$_SESSION['loginUsername'] = $username;
//Register remote IP-Address
$_SESSION['loginIP'] = $_SERVER['REMOTE_ADDR'];
}
} else {
$message = "This username / password combination is incorrect. \nEither check your Login Information and try again or contact the System Administrator.";
$smarty->assign('authMsg', $message);
$smarty->assign($_POST);
$content = $smarty->fetch('./logon/tm0.logon.logon_err.tpl.html');
include_once './config/disconnect.inc.php';
}
示例2: Authentication
SmartyValidate::register_validator('password', 'oldpassword', 'notEmpty');
SmartyValidate::register_validator('password1', 'newpassword:6:-1', 'isLength');
SmartyValidate::register_validator('password2', 'newpassword:confpassword', 'isEqual');
// display form
} else {
// validate after a POST
SmartyValidate::connect($smarty);
if (SmartyValidate::is_valid($_POST)) {
SmartyValidate::disconnect();
// no errors, done with SmartyValidate
#ccreate authenticatio object
$userAuth = new Authentication();
$oldPass = trim($_POST['oldpassword']);
$newPass = trim($_POST['newpassword']);
$cryptNewPass = crypt($newPass, 'yxpijaui93');
if ($userAuth->authenticateUser($db, $_SESSION['loginUsername'], $oldPass)) {
#perform password update
$updatePass = "UPDATE sionapros_users SET password = '{$cryptNewPass}',change_password = 'No' WHERE username = '{$_SESSION['loginUsername']}'";
if ($userAuth->chgPassword($db, $_SESSION['loginUsername'], $newPass)) {
#set session variable 'chg_pass'
$_SESSION['chg_pass'] = 'done';
$msg = "Password has been changed. Please log out and re-log in to ensure that your new password works.";
$smarty->assign('updateMsg', $msg);
#$content = $smarty->fetch('./main/staff/chg_pass.tpl.html');
} else {
#update failed
$msg = "Action Failed. Please try again later or contact the Administrator.";
$smarty->assign('updateMsg', $msg);
#$content = $smarty->fetch('./main/staff/chg_pass.tpl.html');
}
unset($_SESSION['prevPath']);