本文整理汇总了PHP中Auth::authenticate方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::authenticate方法的具体用法?PHP Auth::authenticate怎么用?PHP Auth::authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth
的用法示例。
在下文中一共展示了Auth::authenticate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_setCredentials
public function test_setCredentials()
{
$fs = \Mockery::mock('League\\Flysystem\\Filesystem');
$fs->shouldReceive('read')->with('/tmp/credentials.php')->andReturn('<?php $credentials = "old hash"; ?>')->once();
$fs->shouldReceive('put')->with('/tmp/credentials.php', '/new password hash/')->andReturn(true)->once();
$auth = new Auth($fs, '/tmp/credentials.php');
$this->assertTrue($auth->authenticate('old hash'));
$auth->setCredentials('new password hash');
$this->assertTrue($auth->authenticate('new password hash'));
}
示例2: test_authenticate2
public function test_authenticate2()
{
//Auth::logout();
$this->assertFalse(Auth::authenticate('test_auth', 'aaa'));
$this->assertFalse(Auth::authenticate('test_auth2', 'password'));
$this->assertNull(Auth::get_logged_in_user());
}
示例3: __construct
public function __construct($request)
{
// Get the token from $request which has been set in the headers
$this->token = $request['token'];
// Get the args which is simply the url without domain and ...
$args = $request['args'];
// This will check if user is authenticated, if not Auth will throw a Error(7) and kills the page
Auth::authenticate($this->token);
// Get the all arguments from url
$this->args = explode('/', rtrim($args, '/'));
// Get the Controller name
$this->endpoint = ucfirst($this->args[0]);
// always the first one is our endpoint , E.g : api/v1/ -> products
// Do a loop on all arguments to find ids and popo names
foreach ($this->args as $arg) {
// Look for an id , either mongo id , or product id !
if (is_mongo_id($arg)) {
$this->id = $arg;
continue;
// continue if the condition is met , go next loop
}
// Check if there is popo with this arg in popo folder
if (popo_exists($this->endpoint, uc_first($arg))) {
$this->popo = uc_first($arg);
}
}
// Request type
$this->request_type = $this->get_request_method();
// PUT and DELETE can be hidden inside of an POST request , check them :
if ($this->request_type == 'POST' && array_key_exists('HTTP_X_HTTP_METHOD', $_SERVER)) {
if ($_SERVER['HTTP_X_HTTP_METHOD'] == "DELETE") {
$this->request_type = 'DELETE';
} else {
if ($_SERVER['HTTP_X_HTTP_METHOD'] == 'PUT') {
$this->request_type = 'PUT';
}
}
}
// Get all inputs
$this->input = @file_get_contents('php://input');
$this->input = json_decode($this->input);
// Check if request method is either POST or PUT and if yes , check if input is empty or not
validate_input($this->input, $this->request_type);
// Get params from GET , if is set
if (isset($_GET)) {
$this->params = $_GET;
// first param is like : /produtcs/34534543 , So we dont need it
array_shift($this->params);
}
// Get params from POST , if is set
if (isset($_POST)) {
foreach ($_POST as $k => $v) {
$this->params[$k] = $v;
}
}
// Define the protocol
$this->protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https" : "http";
}
示例4: login
public function login()
{
if (Input::hasPost("login", "password")) {
$pwd = Load::model("usuario")->crearPassword(Input::post("password"));
$usuario = Input::post("login");
$auth = new Auth("model", "class: usuario", "usuario_nombre: {$usuario}", "usuario_password: {$pwd}");
if ($auth->authenticate()) {
Router::redirect("auth/welcome");
} else {
Flash::error("Usuario o contraseña inválidos!");
}
}
}
示例5: inicio
public function inicio()
{
if (Input::hasPost("user", "password")) {
$pwd = md5(Input::post("password"));
$usuario = Input::post("user");
$auth = new Auth("model", "class: sesion", "user: {$usuario}", "password: {$pwd}");
if ($auth->authenticate()) {
Router::toAction("dashboard");
} else {
Flash::error("Usuario o contraseña invalidos");
}
}
}
示例6: check
/**
* check
*
* @param $username
* @param $password
* @return true/false
*/
public static function check($username, $password)
{
Load::lib('auth');
$password = hash('md5', $password);
$auth = new Auth('model', 'class: usuario', "login: {$username}", "password: {$password}", 'status: A');
if ($auth->authenticate()) {
Session::set(SESSION_KEY, true);
return true;
} else {
self::setError('Error Login!');
Session::set(SESSION_KEY, false);
return false;
}
}
示例7: login
public function login($post)
{
$usuario = $post['usuario'];
$password = sha1($post['password']);
$auth = new Auth("model", "class: Usuario", "nombre_usuario: {$usuario}", "password: {$password}");
$admin = $this->find_by_sql('SELECT * FROM usuario WHERE nombre_usuario="' . $usuario . '"');
if ($admin->admin == 1) {
if ($auth->authenticate()) {
if (Auth::get('admin') == 1) {
return true;
}
} else {
return false;
}
}
}
示例8: validate_login
public function validate_login()
{
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('login-user', 'Username', 'trim|required');
$this->form_validation->set_rules('login-pass', 'Password', 'trim|required');
$this->form_validation->set_message('Invalid username or password.');
if ($this->form_validation->run() == FALSE) {
return false;
} else {
$username = $this->input->post('login-user');
$password = $this->input->post('login-pass');
// If the form fields validate, Authenticate User.
Auth::authenticate($username, $password);
}
}
示例9: login
public function login()
{
//en login susamos el template sin menus
$this->render("login", "portada");
if ($this->has_post("login", "password")) {
$pwd = $this->post("password");
$usuario = $this->post('login');
$auth = new Auth("model", "class: usuario", "username: {$usuario}", "password: {$pwd}");
if ($auth->authenticate()) {
$this->redirect("inicio");
Flash::success("Bienvenido");
} else {
Flash::error("Error, Usuario y/o contraseña incorrecta");
}
}
}
示例10: login
public function login()
{
if ($this->has_post("login", "password")) {
$login = $this->request("login");
/*Tomamos el login del request*/
$password = $this->request("password");
/*Tomamos el pass del request*/
$auth = new Auth("model", "class: Gsusers", "login: {$login}", "password: {$password}");
if ($auth->authenticate()) {
$this->redirect("panel/index");
} else {
Flash::error("Usuario/Password invalido");
$this->redirect("");
}
}
}
示例11: login
public function login()
{
View::template('login');
$usuarios = new Usuarios();
if (Input::post("usuarios")) {
# code...
$pwd = $usuarios->cript(Input::post("usuarios")['password']);
$usuario = Input::post("usuarios")['login'];
$auth = new Auth("model", "class: usuarios", "login: {$usuario}", "password: {$pwd}");
if ($auth->authenticate()) {
View::template('default');
Router::redirect("index/index");
} else {
Flash::error("Login o password invalidos");
}
}
}
示例12: ingresar
function ingresar()
{
Config::set('config.application.breadcrumb', FALSE);
View::template('login-box');
Load::lib('auth');
if ($this->has_post("usuario", "contrasena")) {
$usuario = $this->post("usuario");
$contrasena = $this->post("contrasena");
$auth = new Auth("model", "class: Usuario", "nombreusuario: {$usuario}", "contrasena: {$contrasena}");
if ($auth->authenticate()) {
Router::redirect("administrador/inicioadmin");
//Flash::success("Correcto");
} else {
Flash::error("Falló");
}
}
}
示例13: login
public function login()
{
if (Input::hasPost("login", "password")) {
$pwd = Input::post("password");
$usuario = Input::post("login");
$u = new Usuario();
$pwd = $u->encriptar_password($pwd);
$auth = new Auth("model", "class: usuario", "login: {$usuario}", "password: {$pwd}");
if ($auth->authenticate()) {
Router::redirect("index/dashboard");
die;
} else {
Flash::error("Login o password incorrectos");
}
}
Router::redirect("/");
}
示例14: login
public function login()
{
if (Input::hasPost("usuario", "password", "tipo_usuario")) {
$pwd = Input::post("password");
$usuario = Input::post("usuario");
$tipo_usuario = Input::post("tipo_usuario");
if ($tipo_usuario == "docente") {
$modelo = "profesor";
$campo1 = "dni";
$campo2 = "password";
$pwd = md5($pwd);
$auth = new Auth("model", "class: {$modelo}", "{$campo1}: {$usuario}", "{$campo2}: {$pwd}", "tipo_usuario: 1");
} elseif ($tipo_usuario == "alumno") {
$modelo = "alumno";
$campo1 = "dni";
$campo2 = "dni";
$auth = new Auth("model", "class: {$modelo}", "{$campo1}: {$usuario}", "{$campo2}: {$pwd}");
} else {
$modelo = "profesor";
$campo1 = "dni";
$campo2 = "password";
$pwd = md5($pwd);
$auth = new Auth("model", "class: {$modelo}", "{$campo1}: {$usuario}", "{$campo2}: {$pwd}", "tipo_usuario: 0");
}
if ($auth->authenticate()) {
/*agregar un parametro para saber que tipo de usuario es*/
$_SESSION['KUMBIA_AUTH_IDENTITY'][Config::get('config.application.namespace_auth')]['tipousuario'] = $tipo_usuario;
if ($tipo_usuario == "alumno") {
Flash::valid("Alumno");
Router::redirect("perfil/");
}
if ($tipo_usuario == "docente") {
Flash::valid("Docente");
Router::redirect("perfil/");
}
if ($tipo_usuario == "administrador") {
Flash::valid("Administrador");
Router::redirect("profesor/");
}
} else {
Flash::error("El Nombre de Usuario o contraseña son incorrectos");
Router::redirect("/");
}
}
}
示例15: login
function login($loginid, $password, $expires = null)
{
$ctx = Model_Context::getInstance();
$loginid = POD::escapeString($loginid);
$blogid = getBlogId();
$userid = Auth::authenticate($blogid, $loginid, $password);
if ($userid === false) {
return false;
}
if (empty($_POST['save'])) {
setcookie('TSSESSION_LOGINID', '', time() - 31536000, $ctx->getProperty('service.path') . '/', $ctx->getProperty('service.domain'));
} else {
setcookie('TSSESSION_LOGINID', $loginid, time() + 31536000, $ctx->getProperty('service.path') . '/', $ctx->getProperty('service.domain'));
}
if (in_array("group.writers", Acl::getCurrentPrivilege())) {
Session::authorize($blogid, $userid, $expires);
}
return true;
}