本文整理汇总了PHP中Auth::basic方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::basic方法的具体用法?PHP Auth::basic怎么用?PHP Auth::basic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth
的用法示例。
在下文中一共展示了Auth::basic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
/*
|--------------------------------------------------------------------------
| Authentication Filters
|--------------------------------------------------------------------------
|
| The following filters are used to verify that the user of the current
| session is logged into this application. The "basic" filter easily
| integrates HTTP Basic authentication for quick, simple checking.
|
*/
$router->filter('auth.basic', function () {
return Auth::basic();
});
/*
|--------------------------------------------------------------------------
| Guest Filter
|--------------------------------------------------------------------------
|
| The "guest" filter is the counterpart of the authentication filters as
| it simply checks that the current user is not logged in. A redirect
| response will be issued if they are, which you may freely change.
|
*/
$router->filter('guest', function () {
if (Auth::check()) {
return Redirect::to('/');
}
});
parent::boot($router);
}
示例2: authenticationCheck
function authenticationCheck()
{
$user = new \DB\SQL\Mapper($this->db, 'user');
$auth = new \Auth($user, array('id' => 'name', 'pw' => 'password'));
$loginResult = $auth->basic();
return $loginResult;
}
示例3: login
public function login()
{
$redirect = Session::get('redirect');
// check we're not already logged in
if (!Auth::check()) {
// do auth
Auth::basic('username');
//check again
if (Auth::check()) {
// auth successful
$user = Auth::user();
$user->touchLoggedInDate();
// update logged_in_at to current datetime
Auth::login($user, true);
// login and set remember_token
} else {
// auth failed
$headers = array('WWW-Authenticate' => 'Basic');
$params = array('title' => 'Login failed', 'message' => 'Invalid username/password.');
Session::flash('redirect', $redirect);
return Response::view('message', $params, 401, $headers);
}
}
if ($redirect) {
return Redirect::to($redirect);
} else {
return Redirect::home();
}
}
示例4: beforeRoute
function beforeRoute($f3, $params)
{
$user = new \DB\SQL\Mapper($f3->get('DB'), 'USERS');
$auth = new \Auth($user, array('id' => 'name', 'pw' => 'pass'));
$loginStatus = $auth->basic(function ($pw) {
return sha1($pw);
});
if (!$loginStatus) {
$f3->error(401);
}
}
示例5: reports
public function reports()
{
Auth::basic('username');
if (!Auth::check()) {
// do auth
Auth::basic('username');
if (!Auth::check()) {
return Response::make(View::make('unauth', array()), 401)->header('WWW-Authenticate', 'Basic');
}
}
Report::clearCache();
$reports = Report::select()->with('pathRecord', 'user')->orderBy('created_at', 'desc')->paginate(30);
return View::make('reports', array('reports' => $reports, 'pageTitle' => 'Reports'));
}
示例6: suggest
public function suggest()
{
Auth::basic('username');
if (!Auth::check()) {
// do auth
Auth::basic('username');
if (!Auth::check()) {
return Response::make(View::make('unauth', array()), 401)->header('WWW-Authenticate', 'Basic');
}
}
$term = Input::get('term');
$result = Search::suggest($term);
return Response::json($result);
}
示例7: register
public function register()
{
$username = Input::get('username');
$password = Input::get('password');
if (!Auth::check()) {
Auth::basic('username');
}
$user = Auth::user();
if (!$user || !$user->hasSuper()) {
return Response::json(array('result' => false, 'message' => 'Access denied'));
}
if (!User::usernameIsUnique($username)) {
return Response::json(array('result' => false, 'message' => 'Username provided is already registered.'));
}
if ($username && $password) {
User::register($username, $password);
return Response::json(array('result' => true));
} else {
return Response::json(array('result' => false, 'message' => 'Invalid details provided'));
}
}
示例8: recent
public function recent()
{
Auth::basic('username');
if (!Auth::check()) {
// do auth
Auth::basic('username');
if (!Auth::check()) {
return Response::make(View::make('unauth', array()), 401)->header('WWW-Authenticate', 'Basic');
}
}
$records = $this->getRecentRecords();
$paths = array();
$bucket = array();
$currentParent = null;
foreach ($records as $record) {
$path = Path::fromRelative($record->path);
if ($path->exists()) {
$path->record = $record;
$parent = $path->getParent();
if ($currentParent === null) {
$currentParent = $parent;
}
// if this path's parent is the same as the previous, add it to the bucket
if ($parent->getHash() === $currentParent->getHash()) {
$bucket[] = $path;
} else {
// if's different, add it to the paths array and start a new bucket
$paths[] = array('parent' => $currentParent, 'paths' => $bucket);
$bucket = array($path);
$currentParent = $parent;
}
}
}
if (count($bucket) > 0) {
$paths[] = array('parent' => $currentParent, 'paths' => $bucket);
}
return View::make('recent', array('pathBuckets' => $paths, 'pageTitle' => 'Recent uploads'));
}
示例9: app_path
Validator::extend('map', 'EntityValidator@validateMap');
Validator::extend('location', 'EntityValidator@validateLocation');
Validator::extend('amenities', 'EntityValidator@validateAmenities');
Validator::extend('body', 'EntityValidator@validateBody');
Validator::extend('time', 'ReservationValidator@validateTime');
Validator::extend('customer', 'ReservationValidator@validateCustomer');
/*
|--------------------------------------------------------------------------
| Require The Filters File
|--------------------------------------------------------------------------
|
| Next we will load the filters file for the application. This gives us
| a nice separate location to store our route and application filter
| definitions instead of putting them all in the main routes file.
|
*/
require app_path() . '/filters.php';
Route::filter('auth.basic', function () {
Config::set('auth.model', 'Cluster');
Auth::basic('clustername');
if (Auth::guest()) {
return Response::json(array("success" => 0, "errors" => array(array("code" => 401, "type" => "Invalid credentials", "message" => "The credentials you provided are invalid."))), 401);
}
return;
});
use Hautelook\Phpass\PasswordHash;
use Illuminate\Auth\Guard;
Auth::extend('flatturtle_phpass', function ($app) {
$hasher = new PasswordHash(8, false);
return new Guard(new FlatTurtleClusterProvider($hasher, 'Cluster'), $app['session.store']);
});
示例10: function
| The following filters are used to verify that the user of the current
| session is logged into this application. The "basic" filter easily
| integrates HTTP Basic authentication for quick, simple checking.
|
*/
Route::filter('auth', function () {
if (Auth::guest()) {
if (Request::ajax()) {
return Response::make('Unauthorized', 401);
} else {
return Redirect::guest('login');
}
}
});
Route::filter('auth.basic', function () {
return Auth::basic('staff_username');
});
/*
|--------------------------------------------------------------------------
| Guest Filter
|--------------------------------------------------------------------------
|
| The "guest" filter is the counterpart of the authentication filters as
| it simply checks that the current user is not logged in. A redirect
| response will be issued if they are, which you may freely change.
|
*/
Route::filter('guest', function () {
if (Auth::check()) {
return Redirect::to('/');
}
示例11: function
$f3->route('POST /ainesosa/valinta/poista', 'Ingredient->post_delete_ingredient');
# ATERIA AJAX
$f3->route('GET /ajax/annos/haeAinesosat/@id/json', 'Meal->get_ingredients_json');
$f3->route('GET /ajax/annos/haeAinesosat/@id/json [ajax]', 'Meal->get_ingredients_json');
$f3->route('GET /ajax/annos/json', 'Meal->get_json');
# AINESOSA AJAX
$f3->route('GET /ajax/ainesosa/json [ajax]', 'Ingredient->get_all_json');
$f3->route('GET /ajax/ainesosa/json', 'Ingredient->get_all_json');
# ALLERGIA AJAX
$f3->route('GET /ajax/allergia/json', 'Allergy::ajax_map_to_id');
$f3->route('GET /ajax/allergia/json [ajax]', 'Allergy::ajax_map_to_id');
$f3->route('GET /login', function ($f3) {
$user = new \DB\SQL\Mapper($f3->get('DB'), 'USERS');
$auth = new \Auth($user, array('id' => 'name', 'pw' => 'pass'));
$loginStatus = $auth->basic(function ($pw) {
return sha1($pw);
});
if ($loginStatus) {
$f3->reroute("/");
} else {
$f3->error(401);
}
});
$f3->route('GET /logout', function ($f3) {
echo print_r($_SESSION);
$f3->clear('SESSION');
echo 'logged out';
});
#API ROUTES
$f3->route('GET /api/annos/json', 'ApiController->get_meals');
$f3->route('GET /api/allergia/json', 'ApiController->get_allergies');
示例12: basicAuthenticate
/**
* Basic Authentication for login:password of developer
* Check that the credentials match the database
* Cache result for 60 seconds
* @return boolean success/failure
*/
protected function basicAuthenticate($f3, $params)
{
$auth = new \Auth(new \DB\SQL\Mapper(\Registry::get('db'), '<TABLE>', array('login', 'password'), 60), array('id' => 'login', 'pw' => 'password'));
return $auth->basic(function () use($auth, $f3) {
});
}
示例13: function
*/
Route::filter('auth', function () {
if (Auth::guest()) {
if (Request::ajax()) {
return Response::make('Unauthorized', 401);
} else {
return Redirect::guest('login');
}
}
});
Route::filter('auth.basic', function () {
//return Auth::basic();
if (Input::get('fb')) {
return Auth::basic("facebook_id");
} else {
return Auth::basic("username");
}
//return (Auth::basic("username")||Auth::basic("facebook_id"));
});
/*
|--------------------------------------------------------------------------
| Guest Filter
|--------------------------------------------------------------------------
|
| The "guest" filter is the counterpart of the authentication filters as
| it simply checks that the current user is not logged in. A redirect
| response will be issued if they are, which you may freely change.
|
*/
Route::filter('guest', function () {
if (Auth::check()) {
示例14: function
| session is logged into this application. The "basic" filter easily
| integrates HTTP Basic authentication for quick, simple checking.
|
*/
Route::filter('auth', function () {
if (Auth::guest()) {
if (Request::ajax()) {
$sendMsgArray = array("ret_code" => -10052, "msg" => Lang::get('errormessages.-10052'));
return Response::json($sendMsgArray);
} else {
return Redirect::guest('login');
}
}
});
Route::filter('auth.basic', function () {
return Auth::basic('wy_user_name');
});
/*
|--------------------------------------------------------------------------
| Guest Filter
|--------------------------------------------------------------------------
|
| The "guest" filter is the counterpart of the authentication filters as
| it simply checks that the current user is not logged in. A redirect
| response will be issued if they are, which you may freely change.
|
*/
Route::filter('guest', function () {
if (Auth::check()) {
return Redirect::to('/');
}
示例15: function
|--------------------------------------------------------------------------
| Authentication Filters
|--------------------------------------------------------------------------
|
| The following filters are used to verify that the user of the current
| session is logged into this application. The "basic" filter easily
| integrates HTTP Basic authentication for quick, simple checking.
|
*/
Route::filter('auth', function () {
if (Auth::guest()) {
return Redirect::guest('admin/login');
}
});
Route::filter('auth.basic', function () {
return Auth::basic('member_name');
});
/*
|--------------------------------------------------------------------------
| Guest Filter
|--------------------------------------------------------------------------
|
| The "guest" filter is the counterpart of the authentication filters as
| it simply checks that the current user is not logged in. A redirect
| response will be issued if they are, which you may freely change.
|
*/
Route::filter('guest', function () {
if (Auth::check()) {
return Redirect::to('admin');
}