本文整理汇总了PHP中auth::login方法的典型用法代码示例。如果您正苦于以下问题:PHP auth::login方法的具体用法?PHP auth::login怎么用?PHP auth::login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auth
的用法示例。
在下文中一共展示了auth::login方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: change_provider
static function change_provider($new_provider)
{
$current_provider = module::get_var("gallery", "identity_provider");
if (!empty($current_provider)) {
module::uninstall($current_provider);
}
try {
IdentityProvider::reset();
$provider = new IdentityProvider($new_provider);
module::set_var("gallery", "identity_provider", $new_provider);
if (method_exists("{$new_provider}_installer", "initialize")) {
call_user_func("{$new_provider}_installer::initialize");
}
module::event("identity_provider_changed", $current_provider, $new_provider);
auth::login($provider->admin_user());
Session::instance()->regenerate();
} catch (Exception $e) {
static $restore_already_running;
// In case of error, make an attempt to restore the old provider. Since that's calling into
// this function again and can fail, we should be sure not to get into an infinite recursion.
if (!$restore_already_running) {
$restore_already_running = true;
// Make sure new provider is not in the database
module::uninstall($new_provider);
// Lets reset to the current provider so that the gallery installation is still
// working.
module::set_var("gallery", "identity_provider", null);
IdentityProvider::change_provider($current_provider);
module::activate($current_provider);
message::error(t("Error attempting to enable \"%new_provider\" identity provider, " . "reverted to \"%old_provider\" identity provider", array("new_provider" => $new_provider, "old_provider" => $current_provider)));
$restore_already_running = false;
}
throw $e;
}
}
示例2: load_user
/**
* Make sure that we have a session and group_ids cached in the session.
*/
static function load_user()
{
try {
// Call IdentityProvider::instance() now to force the load of the user interface classes.
// We are about to load the active user from the session and which needs the user definition
// class, which can't be reached by Kohana's heiracrchical lookup.
IdentityProvider::instance();
$session = Session::instance();
if (!($user = $session->get("user"))) {
self::set_active_user($user = self::guest());
}
// The installer cannot set a user into the session, so it just sets an id which we should
// upconvert into a user.
// @todo set the user name into the session instead of 2 and then use it to get the user object
if ($user === 2) {
auth::login(IdentityProvider::instance()->admin_user());
}
if (!$session->get("group_ids")) {
$ids = array();
foreach ($user->groups() as $group) {
$ids[] = $group->id;
}
$session->set("group_ids", $ids);
}
} catch (Exception $e) {
// Log it, so we at least have so notification that we swallowed the exception.
Kohana_Log::add("error", "load_user Exception: " . $e->getMessage() . "\n" . $e->getTraceAsString());
try {
Session::instance()->destroy();
} catch (Exception $e) {
// We don't care if there was a problem destroying the session.
}
url::redirect(item::root()->abs_url());
}
}
示例3: login
public function login()
{
if (input::post('username') && input::post('password') && auth::login(input::post('username'), input::post('password'), self::AUTH_REALM)) {
$this->index();
} else {
return $this->access_denied();
}
}
示例4: index
public function index()
{
$username = Input::instance()->post("user");
$password = Input::instance()->post("password");
if (empty($username) || auth::too_many_failures($username)) {
throw new Rest_Exception("Forbidden", 403);
}
$user = identity::lookup_user_by_name($username);
if (empty($user) || !identity::is_correct_password($user, $password)) {
module::event("user_login_failed", $username);
throw new Rest_Exception("Forbidden", 403);
}
auth::login($user);
rest::reply(rest::access_key());
}
示例5: _auth
private function _auth($url)
{
$form = auth::get_login_form($url);
$valid = $form->validate();
if ($valid) {
$user = identity::lookup_user_by_name($form->login->inputs["name"]->value);
if (empty($user) || !identity::is_correct_password($user, $form->login->password->value)) {
log::warning("user", t("Failed login for %name", array("name" => $form->login->inputs["name"]->value)));
$form->login->inputs["name"]->add_error("invalid_login", 1);
$valid = false;
}
}
if ($valid) {
auth::login($user);
}
// Either way, regenerate the session id to avoid session trapping
Session::instance()->regenerate();
return array($valid, $form);
}
示例6: party
include_once "modules/party/class_party.php";
$party = new party();
} else {
// If without party-module: just give a fake ID, for many modules need it
class party
{
var $party_id;
}
$party = new party();
$party->party_id = (int) $cfg['signon_partyid'];
}
if ($config['environment']['configured'] != 0) {
if ($_GET['mod'] == 'auth') {
switch ($_GET['action']) {
case 'login':
$auth = $authentication->login($_POST['email'], $_POST['password']);
break;
case 'logout':
$auth = $authentication->logout();
$_GET['mod'] = 'home';
break;
case 'switch_to':
// Switch to user
$authentication->switchto($_GET["userid"]);
break;
case 'switch_back':
// Switch back to Adminuser
$authentication->switchback();
break;
}
}
示例7: first
public function first($hash)
{
$pending_user = ORM::factory("pending_user")->where("hash", "=", $hash)->where("state", "=", 2)->find();
if ($pending_user->loaded()) {
// @todo add a request date to the pending user table and check that it hasn't expired
$user = identity::lookup_user_by_name($pending_user->name);
if (!empty($user)) {
auth::login($user);
Session::instance()->set("registration_first_usage", true);
$pending_user->delete();
}
url::redirect(item::root()->abs_url());
} else {
message::warning(t("Your account is ready to use so please login."));
}
url::redirect(item::root()->abs_url());
}
示例8: Upload
$upload = new Upload();
//коммент
call_user_func(array($upload, 'out'));
break;
case 'auth':
header('Content-Type: application/json');
$ident = new auth();
if (isset($_GET['auth'])) {
$auth = $_GET['auth'];
switch ($auth) {
case 'user':
$ident->get_user();
break;
case 'logout':
$ident->logount();
break;
default:
$ident->login();
break;
}
} else {
$ident->login();
}
break;
default:
// header('Content-Type: application/json');
$recipes = new Recipes();
$shag = $_GET['shag'];
echo $recipes->getRecipes($shag);
break;
}
示例9: _auth
/**
* authenticate the user
*
* @param string $url
* @return boolean
*/
private function _auth($url)
{
$form = auth::get_login_form($url);
$validform = $form->validate();
$valid = false;
if ($validform) {
// retrieve the values from the form
$name = $form->login->inputs["name"]->value;
$pass = $form->login->password->value;
// do we have a user?
$user = identity::lookup_user_by_name($name);
$validuser = empty($user) ? false : true;
// is the user authentic?
$checkpass = $this->_checkpass($name, $pass);
/*
* we are concerned with these three possibilities:
* 1. there is no valid user or no valid password
* 2. there is no valid user but a valid password
* 3. there is a valid user and a valid password
*/
// 1. there is no valid user or no valid password: error
if (!$validuser || !$checkpass) {
$form->login->inputs["name"]->add_error("invalid_login", 1);
$name = $form->login->inputs["name"]->value;
log::warning("user", t("Failed login for %name", array("name" => $name)));
module::event("user_auth_failed", $name);
}
// 2. there is no valid user but a valid password: create account if allowed
if (!$validuser && $checkpass && $this->create_account) {
$account = $this->pam_auth->getAccount();
if ($account) {
$password = md5(uniqid(mt_rand(), true));
$new_user = identity::create_user($account->name, $account->full_name, $password, $account->email);
$new_user->url = '';
$new_user->admin = false;
$new_user->guest = false;
$new_user->save();
$user = identity::lookup_user_by_name($account->name);
$validuser = empty($user) ? false : true;
}
}
// 3. there is a valid user and a valid password: load user account
if ($validuser && $checkpass) {
auth::login($user);
$valid = true;
}
}
// regenerate the session id to avoid session trapping
Session::instance()->regenerate();
return array($valid, $form);
}
示例10: User
<?php
// Initialize
global $template;
$registration_successful = false;
// Create new user
if (isset($_POST['submit']) && $_POST['submit'] == tr('Register Now')) {
$user = new User();
$userid = $user->create();
// Redirect to payment, if needed
if ($template->has_errors != 1) {
// Login
$auth = new auth();
$auth->login('public', false);
// Redirect, as needed
if ($_POST['is_payment'] == 1) {
$template = new template('pay');
$template->add_message("Successfully created new user, {$_POST['username']}. You may now login with your account.");
$template->parse();
exit(0);
} else {
$template->add_message("Successfully created new user, {$_POST['username']}. You may now login with your account.");
}
}
}
// Set variables
if (isset($_REQUEST['is_payment']) && $_REQUEST['is_payment'] == 1) {
$is_payment = 1;
$amount = $_REQUEST['amount'];
$currency = $_REQUEST['currency'];
$wallet_id = $_REQUEST['wallet_id'];
示例11: session
<?php
require_once '../../config/configuracao.php';
require_once $BASE_DIR . 'lib/adLDAP.php';
require_once $BASE_DIR . 'core/data/connection_factory.php';
require_once $BASE_DIR . 'core/login/session.php';
require_once $BASE_DIR . 'core/login/auth.php';
$sessao = new session($param_conn);
// INICIA UM NOVO PROCESSO DE LOGIN
if (isset($_POST['modulo'])) {
$conn = new connection_factory($param_conn);
// verifica usuário na base LDAP
$adLdap = new adLDAP($param_ldap);
$autentica = new auth($BASE_URL, $adLdap);
$autentica->log_file($BASE_DIR . 'logs/login.log');
if ($autentica->login(trim($_POST['uid']), trim($_POST['pwd']), $_POST['modulo'], $conn) === TRUE) {
// REDIRECIONA DE ACORDO COM O MODULO SELECIONADO
switch ($_SESSION['sa_modulo']) {
case 'sa_login':
exit(header('Location: ' . $BASE_URL . 'app/'));
break;
case 'web_diario_login':
exit(header('Location: ' . $BASE_URL . 'app/web_diario/'));
break;
case 'aluno_login':
exit(header('Location: ' . $BASE_URL . 'app/aluno'));
break;
default:
exit(header('Location: ' . $BASE_URL . 'index.php?sa_msg=Sessão inválida'));
}
} else {
示例12: auth
<?php
require_once './../persistence.class.php';
require_once './../auth.class.php';
$uid = "eddadmin";
$pass = "root@eddadmin_0x";
$auth = new auth($uid);
$user = $auth->login($uid, $pass);
$status = $user->authenticated() ? "user logged in: {$user->username}" : "auth failed<br />reason: {$user->fail_reason()}";
persistence::persist_user($user);
echo "user: {$uid}, password: {$pass} <br />";
echo $status;
示例13:
echo '
<form action="" method="post">
<input type="text" name="nick" placeholder="Логин" required>
<input type="password" name="pass" placeholder="Пароль" required>
<input type="submit" name="login" value="Авторизироваться!">
</form>
<a href="?action=register">Register</a>
';
}
if (isset($_GET['action']) and $_GET['action'] == 'logout') {
//logouting
$user->logout();
}
if (isset($_POST['login'])) {
//logging
if ($user->login($_POST['nick'], $_POST['pass'])) {
} else {
echo $user->error_msg;
}
}
if (isset($_POST['register'])) {
//registering
if ($user->register($_POST['nick'], $_POST['email'], $_POST['pass'], $_POST['r_pass'], $_POST['name'])) {
} else {
echo $user->error_msg;
}
}
if (isset($_POST['check'])) {
//validating
if (!$user->verify($_POST['code'])) {
echo $user->error_msg;
示例14: elseif
$func->error(t('Bitte gib ein Kennwort ein!'), "index.php?mod=install&action=wizard&step=6");
} elseif ($_POST["password"] != $_POST["password2"]) {
$func->error(t('Das Passwort und seine Verifizierung stimmen nicht überein!'), "index.php?mod=install&action=wizard&step=6");
} else {
// Check for existing Admin-Account.
$row = $db->qry_first("SELECT email FROM %prefix%user WHERE email=%string%", $_POST["email"]);
// If found, update password
if ($row['email']) {
$db->qry("UPDATE %prefix%user SET password = %string%, type = '3' WHERE email=%string%", md5($_POST["password"]), $_POST["email"]);
} else {
$db->qry("INSERT INTO %prefix%user SET username = 'ADMIN', firstname = 'ADMIN', name = 'ADMIN', email=%string%, password = %string%, type = '3'", $_POST["email"], md5($_POST["password"]));
$userid = $db->insert_id();
}
include_once "inc/classes/class_auth.php";
$authentication = new auth();
$authentication->login($_POST["email"], $_POST["password"]);
}
// No break!
// No break!
case 8:
if (!$func->admin_exists()) {
$func->information(t('Du musst einen Admin-Account anlegen, um fortfahren zu können'));
$_GET['step'] = 6;
}
break;
}
switch ($_GET["step"]) {
// Check Environment
default:
$dsp->NewContent(t('Lansuite Installation und Administration'), t('Willkommen bei der Installation von Lansuite.<br />Im ersten Schritt wird die Konfiguration deines Webservers überprüft.<br />Sollte alles korrekt sein, so drücke bitte am Ende der Seite auf <b>Weiter</b> um mit der Eingabe der Grundeinstellungen fortzufahren.'));
$dsp->SetForm("index.php?mod=install&action=wizard");
示例15: _login
private function _login(&$input, &$reply)
{
$uname = trim($input->post('uname'));
if (empty($uname)) {
$reply->send(gallery_remote::LOGIN_MISSING);
} else {
$user = user::lookup_by_name($uname);
$password = trim($input->post('password'));
if ($user && user::is_correct_password($user, $password)) {
auth::login($user);
Session::instance()->regenerate();
$reply->set('debug_user', $user->name);
$reply->set('status_text', 'Login successful.');
$reply->send();
} else {
$reply->send(gallery_remote::PASSWD_WRONG);
}
}
}