当前位置: 首页>>代码示例>>PHP>>正文


PHP Auth::onceBasic方法代码示例

本文整理汇总了PHP中Auth::onceBasic方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::onceBasic方法的具体用法?PHP Auth::onceBasic怎么用?PHP Auth::onceBasic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Auth的用法示例。


在下文中一共展示了Auth::onceBasic方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: auth

 protected function auth()
 {
     if (Auth::onceBasic("username")) {
         return Auth::user()->isDev();
     }
     return false;
 }
开发者ID:ZR2,项目名称:site,代码行数:7,代码来源:GitController.php

示例2: download

 protected function download(Path $path)
 {
     // check basic auth headers as well, so if specified,
     // client doesn't have to go through the login and cookie dance.
     Auth::onceBasic("username");
     // check we're logged in
     if (!Auth::check()) {
         Session::flash('redirect', URL::current());
         return Redirect::route('login');
     }
     // record the download in the db
     $record = $path->loadCreateRecord($path);
     $record->downloaded_at = $record->freshTimestamp();
     $record->increment('downloads');
     $record->save();
     $isMisc = strpos($path->getRelative(), '/Misc/') === 0;
     if ($isMisc || $path->isSafeExtension()) {
         // check if the extension is safe to download
         $file = new AsciiSafeDownloadFile($path->getPathname());
         // see comments in AsciiSafeDownloadFile class
         $baseName = $path->getBasename();
         $baseName = str_replace('%', '', $baseName);
         try {
             return Response::download($file, $baseName);
         } catch (InvalidArgumentException $e) {
             App::abort(500, 'This file has a malformed filename. Please contact an admin.');
         }
     } else {
         App::abort(403, sprintf('File type "%s" not allowed', $path->getExtension()));
     }
 }
开发者ID:Lord-Simon,项目名称:MangaIndex,代码行数:31,代码来源:BaseController.php

示例3: authcheck

 public function authcheck()
 {
     Auth::onceBasic('username');
     if (Auth::check()) {
         return Response::make('', 204);
     } else {
         return Response::make('', 401, array('WWW-Authenticate' => 'Basic'));
     }
 }
开发者ID:Lord-Simon,项目名称:MangaIndex,代码行数:9,代码来源:UsersController.php

示例4: function

// Filtro de clase administrador
Route::filter('admin', function () {
    if (!Auth::user()->admin) {
        Session::flash('message', "No tiene Permisos para acceder a esta opción, si piensa que es un error por favor contacte con su administrador");
        return Redirect::to('/');
    }
});
// Filtro de las Api
Route::filter('api', function () {
    header('Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS');
    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization,  Key, Auth-Token');
    if (Request::method() != "OPTIONS") {
        if (Request::header("Auth-Token", null) != null) {
            $user = User::find(Crypt::decrypt(Request::header("Auth-Token")));
            Auth::setUser($user);
        } else {
            return Auth::onceBasic('email');
        }
    }
});
Route::filter('ajax', function () {
    if (!Request::ajax()) {
        return Response::make('Unauthorized', 401);
    }
});
// amarrando el filtro a todas las direcciones admin
Route::when('admin', 'auth|admin');
Route::when('admin/*', 'auth|admin');
//Mismo caso para API
Route::when('api/*', 'api');
开发者ID:seedgabo,项目名称:condominio,代码行数:31,代码来源:filters.php

示例5: function

    	App::abort(400, "Invalid token");
    }
    */
    if (Auth::guest()) {
        if (Request::ajax()) {
            return Response::make('Unauthorized', 401);
        } else {
            return Redirect::guest('login');
        }
    }
});
Route::filter('auth.basic', function () {
    return Auth::basic('username');
});
Route::filter('basic.once', function () {
    return Auth::onceBasic();
});
/*
|--------------------------------------------------------------------------
| 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('/');
    }
开发者ID:jhoansebastianlara,项目名称:esclinicadigital,代码行数:31,代码来源:filters.php

示例6: header

            Auth::logout();
            Session::flush();
            header("HTTP/1.1 404 Page Not Found", true, 404);
            exit("You cannot do this.");
        }
    }
});
Route::filter('force.ssl', function () {
    if (route('home') != 'http://demo.noshchartingsystem.com:444/nosh' && route('home') != 'http://192.168.1.163/nosh' && route('home') != 'http://localhost/nosh' && route('home') != 'http://162.243.111.18/nosh' && route('home') != 'http://uma.noshchartingsystem.com/nosh') {
        if (!Request::secure()) {
            return Redirect::secure(Request::path());
        }
    }
});
Route::filter('auth.basic', function () {
    return Auth::onceBasic('username');
});
Route::filter('auth.token', function () {
    $payload = Request::header('Authorization');
    $open_id_url = str_replace('/nosh', '/uma-server-webapp/', URL::to('/'));
    $practice = DB::table('practiceinfo')->where('practice_id', '=', '1')->first();
    $client_id = $practice->uma_client_id;
    $client_secret = $practice->uma_client_secret;
    if ($payload) {
        // RPT, Perform Token Introspection
        $rpt = str_replace('Bearer ', '', $payload);
        $oidc = new OpenIDConnectClient($open_id_url, $client_id, $client_secret);
        $oidc->refresh($practice->uma_refresh_token, true);
        $result_rpt = $oidc->introspect($rpt);
        if ($result_rpt['active'] == false) {
            // Inactive RPT, Request Permission Ticket
开发者ID:carlosqueiroz,项目名称:nosh-core,代码行数:31,代码来源:routes.php

示例7: function

<?php

Route::filter('token', function () {
    $token = AccessToken::where('token', Input::get('token'))->first();
    if (!$token) {
        return Response::json(array('status' => 'Unauthorized'));
    }
});
Route::filter('auth', function () {
    if (Auth::onceBasic()) {
        return Response::json(['error' => ['message' => 'Invalid credentials', 'status_code' => 401]], 401);
    }
});
Route::filter('bearer', function () {
    $header = Request::header('Authorization');
    if (!$header) {
        return Response::json(['error' => ['message' => 'Unauthorized', 'status_code' => 401]], 401);
    }
    $token = explode(' ', $header)[1];
    if ($token) {
        $device = Device::where('auth_token', $token)->orderBy('id', 'desc')->first();
        if (!is_null($device)) {
            try {
                Auth::onceUsingId($device->user_id);
            } catch (Exception $e) {
                return Response::json(['error' => ['message' => $e->getMessage(), 'status_code' => 500]], 500);
            }
        } else {
            return Response::json(['error' => ['message' => 'Invalid token', 'status_code' => 401]], 401);
        }
    } else {
开发者ID:SenhorBardell,项目名称:yol,代码行数:31,代码来源:filters.php

示例8: 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::onceBasic("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('/');
    }
开发者ID:cayohenrique,项目名称:laravelRestApi,代码行数:31,代码来源:filters.php

示例9: function

/*
|--------------------------------------------------------------------------
| CSRF Protection Filter
|--------------------------------------------------------------------------
|
| The CSRF filter is responsible for protecting your application against
| cross-site request forgery attacks. If this special token in a user
| session does not match the one given in this request, we'll bail.
|
*/
Route::filter('csrf', function () {
    if (Session::token() !== Input::get('_token')) {
        throw new Illuminate\Session\TokenMismatchException();
    }
});
/*
|--------------------------------------------------------------------------
| API Filter
|--------------------------------------------------------------------------
|
| For RESTful API
|
*/
Route::filter('auth.api', function () {
    $message = '無效的憑證。';
    $headers = ['WWW-Authenticate' => 'Basic'];
    $response = Auth::onceBasic('email');
    if (!is_null($response)) {
        return Response::json($message, 401, $headers);
    }
});
开发者ID:htchien,项目名称:prayerweb,代码行数:31,代码来源:filters.php


注:本文中的Auth::onceBasic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。