本文整理汇总了PHP中User::authenticate方法的典型用法代码示例。如果您正苦于以下问题:PHP User::authenticate方法的具体用法?PHP User::authenticate怎么用?PHP User::authenticate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::authenticate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* To check if username is valid and existing
* To check if username and password matched
* Validation to proceed to Thread page
**/
public function index()
{
$username = Param::get('login_name');
$password = Param::get('login_pword');
$user = new User();
$login_info = array('username' => $username, 'password' => $password);
if (!array_filter($login_info)) {
$status = "";
} else {
try {
foreach ($login_info as $key => $value) {
if (!is_complete($value)) {
throw new ValidationException("Please fill up all fields");
}
}
$user_login = $user->authenticate($username, $password);
$_SESSION['username'] = $user_login->username;
redirect(url('thread/index'));
} catch (ValidationException $e) {
$status = notice($e->getMessage(), "error");
} catch (RecordNotFoundException $e) {
$status = notice($e->getMessage(), "error");
}
}
$this->set(get_defined_vars());
}
示例2: authenticate
/**
* Disable BackendUser authentication redirect and cache the result
*/
public function authenticate()
{
if ($this->frontendHelperUserAuthenticated === null) {
$this->frontendHelperUserAuthenticated = \User::authenticate();
}
return $this->frontendHelperUserAuthenticated;
}
示例3: set_current_user
protected function set_current_user()
{
$user = null;
$AnonymousUser = array('id' => 0, 'level' => 0, 'name' => "Anonymous", 'show_samples' => true, 'language' => '', 'secondary_languages' => '', 'pool_browse_mode' => 1, 'always_resize_images' => true, 'ip_addr' => $this->request()->remoteIp());
if (!current_user() && $this->session()->user_id) {
$user = User::where(['id' => $this->session()->user_id])->first();
} else {
if ($this->cookies()->login && $this->cookies()->pass_hash) {
$user = User::authenticate_hash($this->cookies()->login, $this->cookies()->pass_hash);
} elseif (isset($this->params()->login) && isset($this->params()->password_hash)) {
$user = User::authenticate($this->params()->login, $this->params()->password_hash);
} elseif (isset($this->params()->user['name']) && isset($this->params()->user['password'])) {
$user = User::authenticate($this->params()->user['name'], $this->params()->user['password']);
}
$user && $user->updateAttribute('last_logged_in_at', date('Y-m-d H:i:s'));
}
if ($user) {
if ($user->is_blocked() && $user->ban && $user->ban->expires_at < date('Y-m-d H:i:s')) {
$user->updateAttribute('level', CONFIG()->starting_level);
Ban::destroyAll("user_id = " . $user->id);
}
$this->session()->user_id = $user->id;
} else {
$user = new User();
$user->assignAttributes($AnonymousUser, ['without_protection' => true]);
}
User::set_current_user($user);
$this->current_user = $user;
# For convenient access in activerecord models
$user->ip_addr = $this->request()->remoteIp();
Moebooru\Versioning\Versioning::init_history();
if (!current_user()->is_anonymous()) {
current_user()->log($this->request()->remoteIp());
}
}
示例4: login
function login($request)
{
$templateArr = array();
$modelClass = 'User';
$formData = array();
if ($request->user->is_authenticated()) {
HttpResponseRedirect(pjango_ini_get('LOGIN_REDIRECT_URL'));
}
if ($request->POST) {
$form = new Pjango\Contrib\Auth\Forms\LoginForm($request->POST);
try {
if (!$form->is_valid()) {
throw new Exception(pjango_gettext('There are some errors, please correct them below.'));
}
$formData = $form->cleaned_data();
$user = User::authenticate($formData['username'], $formData['password']);
HttpResponseRedirect(pjango_ini_get('LOGIN_REDIRECT_URL'));
} catch (Exception $e) {
Messages::Error($e->getMessage());
}
}
if (!$form) {
$form = new Pjango\Contrib\Auth\Forms\LoginForm($formData);
}
$templateArr['addchange_form'] = $form->as_list();
render_to_response('auth/login.html', $templateArr);
}
示例5: postLogin
public function postLogin()
{
$email = Input::get('email');
$password = Input::get('password');
if (User::authenticate(['email' => $email, 'password' => $password], Input::has('rememberme'))) {
return Redirect::intended('/admin');
}
return Redirect::to('/login')->withInput()->withErrors('Такой связки email и пароля нет.');
}
示例6: create
public function create($username, $password)
{
$user = User::authenticate($username, $password);
if ($user === false) {
Redirect('session/create?error=yes');
}
$_SESSION['user'] = $user;
Redirect('index.php');
}
示例7: store
public static function store()
{
$user = User::authenticate($_POST['username'], $_POST['password']);
if ($user) {
$_SESSION['user'] = $user->id;
Redirect::to("/task", array('message' => "Welcome back."));
}
View::make('session/new.html', array('errors' => array("Wrong password or username.")));
}
示例8: register
function register($info = null)
{
$session = mySession::getInstance();
if ($session->isLoggedIn()) {
$session->logout();
}
if ($info !== null) {
//check email and username they have to be unique
$check = User::getUserByCred($info->email, $info->username);
if (!$check) {
$temp_user = new User();
$temp_user->username = $info->username;
$temp_user->email = $info->email;
$temp_user->password = sha1($info->password);
$temp_user->first_name = $info->first;
$temp_user->last_name = $info->last;
$temp_user->gender = $info->gender;
$temp_user->rights = 'normal';
$temp_user->status = 'current';
$temp_user->valid = 1;
$temp_user->save();
$found_user = User::authenticate($temp_user->username, $temp_user->password);
if ($found_user) {
// log them in
$session->login($found_user);
// grab the account status
$profile_status = $found_user->status;
if ($profile_status != 'current') {
// their account isn't set up so log them out send them to the login page.
$session->logout();
$session->message("Creating your user profile failed");
return false;
} else {
// send verification email.
$to = $found_user->email;
$check = substr($found_user->password, -12);
$subject = "familyhistorydatabase.org verification email";
$message = "You are now registered at familyhistorydatabase.org.\n";
$message = $message . "\nTo verify your membership click on the link below.\nIf you weren't requesting membership, please ignore this email, and we send our appologies!";
$message = $message . "\n" . APIURL . "user/validate/?id=" . $found_user->id . "&validate={$check}";
$from = "noreply@familyhistorydatabase.org";
$headers = "From:" . $from;
mail($to, $subject, $message, $headers);
unset($found_user->password);
return $found_user;
}
}
} else {
// If User Not Found
return false;
}
} else {
// If User Not Found
return false;
}
exit;
}
示例9: login
public static function login($parameters)
{
$id = User::authenticate($parameters);
if ($id != null) {
$content["success"] = "Login was succesful";
} else {
$content["error"] = "Login failed. Username/password combination was invalid.";
}
return $content;
}
示例10: login
public static function login()
{
$params = $_POST;
$user = User::authenticate($params['username'], $params['password']);
if ($user) {
$_SESSION['user'] = $user->id;
Redirect::to(\Slim\Slim::getInstance()->urlFor('index'), array('message' => 'Olet kirjautunut sisään'));
} else {
Redirect::to(\Slim\Slim::getInstance()->urlFor('login'), array('message' => 'Kirjautuminen epäonnistui', 'error' => true));
}
}
示例11: handle_login
public static function handle_login()
{
$params = $_POST;
$user = User::authenticate($params['username'], $params['password']);
if (!$user) {
View::make('user/login.html', array('error' => 'Invalid username or password!', 'username' => $params['username']));
} else {
$_SESSION['user'] = $user->id;
}
Redirect::to('/', array('message' => 'Login successful!'));
}
示例12: handle_login
public static function handle_login()
{
$params = $_POST;
$user = User::authenticate($params['kayttajanimi'], $params['salasana']);
if (!$user) {
View::make('user/login.html', array('error' => 'Väärä käyttäjätunnus tai salasana!', 'kayttajanimi' => $params['kayttajanimi']));
} else {
$_SESSION['user'] = $user->kayttaja_id;
Redirect::to('/', array('message' => 'Tervetuloa takaisin ' . $user->kayttajanimi . '!'));
}
}
示例13: handle_login
public static function handle_login()
{
$params = $_POST;
$user = User::authenticate($params['username'], $params['password']);
if (!$user) {
Redirect::to('/user/login', array('errors' => array('Invalid username or password'), 'attr' => $_POST));
} else {
$_SESSION['user'] = $user->id;
Redirect::to('/', array('message' => 'Welcome back ' . $user->name . '!'));
}
}
示例14: run
public function run($username, $password)
{
global $session;
$userReg = User::authenticate($username, $password);
if ($userReg) {
$session->login($userReg);
return true;
} else {
return false;
}
}
示例15: handle_login
public static function handle_login()
{
$params = $_POST;
$user = User::authenticate($params['username'], $params['password']);
if (!$user) {
View::make('user/login.html', array('error' => 'Väärä käyttätunnus tai salasana', 'username' => $params['username']));
} else {
$_SESSION['user'] = $user->id;
Redirect::to('/memo', array('message' => 'Tervetuloa takaisin ' . $user->name . '.'));
}
}