本文整理汇总了PHP中Sentinel::check方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentinel::check方法的具体用法?PHP Sentinel::check怎么用?PHP Sentinel::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentinel
的用法示例。
在下文中一共展示了Sentinel::check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
public function handle($request, Closure $next)
{
if (!Sentinel::check()) {
return Redirect::route('login');
}
return $next($request);
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Sentinel::check()) {
return redirect('/');
}
return $next($request);
}
示例3: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!\Sentinel::check() || !\Sentinel::getUser()->inRole('admin')) {
return redirect('/');
}
return $next($request);
}
示例4: forgot
public function forgot()
{
if (!Sentinel::check()) {
$this->redirect('/', false);
}
$this->render('login/forgot');
}
示例5: __construct
public function __construct()
{
$this->html = new \stdClass();
$this->html->config = \Pinom\Models\SiteConfig::get();
$this->html->config->version = '2016.01.07α';
//Some hacks to prevent errors, setting default values
if (!isset($this->html->config->calendar)) {
$this->html->config->calendar = 0;
}
if (!isset($this->html->config->site_title)) {
$this->html->config->site_title = 'PiNom';
}
if (!isset($this->html->config->site_description)) {
$this->html->config->site_description = trans('public.default-description');
}
// Folowing lines exctracted from lib/accesslib.phplib/accesslib.php
define('CONTEXT_SYSTEM', 10);
// System context level - only one instance in every system
define('CONTEXT_USER', 30);
// User context level - one instance for each user describing what others can do to user
define('CONTEXT_COURSECAT', 40);
// Course category context level - one instance for each category
define('CONTEXT_COURSE', 50);
// Course context level - one instances for each course
define('CONTEXT_MODULE', 70);
// Course module context level - one instance for each course module
$this->html->user = \Sentinel::check();
}
示例6: getAuthenticated
/**
* Returns the "authenticated" view which simply shows the
* authenticated user.
*
* @return mixed
*/
public function getAuthenticated()
{
if (!Sentinel::check()) {
return Redirect::to('oauth')->withErrors('Not authenticated yet.');
}
return Redirect::route('user.account')->withSuccess('Successfully logged in.');
}
示例7: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Sentinel::check()) {
return redirect(route('home'));
}
return $next($request);
}
示例8: getLogin
public function getLogin()
{
if (\Sentinel::check()) {
return $this->redirect();
}
$loginPostUrl = route('admin.login.post');
return view(\AdminTemplate::view('pages.login'), ['title' => config('admin.title'), 'loginPostUrl' => $loginPostUrl]);
}
示例9: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!\Sentinel::check()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest(route('admin.login'));
}
}
if ($request->route()->getName() == "admin.logout") {
return $next($request);
}
if (count($request->route()->parameters()) == 0) {
//Dashboard or some custom page
if ($request->route()->getName() == "admin.dashboard" || starts_with($request->route()->getName(), "admin.upload.") || starts_with($request->route()->getName(), "elfinder.")) {
if (\Sentinel::hasAnyAccess(['superadmin', 'controlpanel'])) {
return $next($request);
} else {
\Sentinel::logout(null, true);
return redirect()->guest(route('admin.login'));
}
}
} else {
//use dynamic permissions
$route_alias = explode(".", $request->route()->getName());
if (!isset($route_alias[2])) {
$route_alias[2] = 'view';
} elseif ($route_alias[2] == 'update') {
$route_alias[2] = 'edit';
} elseif ($route_alias[2] == 'store') {
$route_alias[2] = 'create';
} else {
$route_alias[2];
}
if (is_null($request->route()->parameters()['adminModel']->permission())) {
if ($route_alias[2] == "view") {
$model_permissions = ["admin." . $request->route()->parameters()['adminModel']->alias() . ".view"];
} else {
$model_permissions = ["admin." . $request->route()->parameters()['adminModel']->alias() . "." . $route_alias[2]];
}
} else {
$model_permissions = explode(",", $request->route()->parameters()['adminModel']->permission());
if ($route_alias[2] == "view") {
$model_permissions[] = "admin." . $request->route()->parameters()['adminModel']->alias() . ".view";
} else {
$model_permissions[] = "admin." . $request->route()->parameters()['adminModel']->alias() . "." . $route_alias[2];
}
}
$model_permissions[] = "superadmin";
if (\Sentinel::hasAnyAccess($model_permissions)) {
return $next($request);
}
}
return redirect()->route('admin.dashboard')->withErrors('Permission denied.');
}
示例10: Login
/**
* Login User
*
* @param AccountLogin $request
*
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function Login(AccountLogin $request)
{
$credentials = array('email' => \Input::get('email'), 'password' => \Input::get('password'));
try {
$user = \Sentinel::authenticate($credentials, \Input::get('remember_me'));
\Sentinel::getUserRepository()->recordLogin($user);
if (\Sentinel::check()) {
return redirect('/');
}
} catch (\Exception $e) {
return redirect('auth/login')->withErrors(array('login' => trans('auth.errors.login')));
}
}
示例11: is_admin
/**
* extending hieu-le/active function
*
* @param int $user_id
*
* @return bool
*/
function is_admin($user_id = null)
{
if ($user_id) {
$user = Sentinel::findById($user_id);
} else {
if (Sentinel::check()) {
$user = Sentinel::getUser();
} else {
return false;
}
}
$admin = Sentinel::findRoleByName('Administrator');
return $user && $user->inRole($admin);
}
示例12: getIndex
public function getIndex()
{
//Get the items from the StoreDB
$store_items = Item::whereRaw("loadout_slot IN ( 'brillen','hats','pets','skin','snorren','piemol','vogel','jetpack' )")->get();
//Sort them
$store_items = $store_items->sortBy(function ($store_item) {
return $store_item->loadout_slot;
//sort them by loadout slot
});
$paymentprovider = DB::table('sd_payment_providers')->orderBy('pos', 'desc')->get();
$user = Sentinel::check();
$sd_items = SDItem::where('visible', '1')->get();
//Build the view
return View::make('item.overview', array('items' => $store_items, 'sditems' => $sd_items, 'payment_providers' => $paymentprovider, 'user' => $user));
}
示例13: login
/**
* process the login submit.
*
* @return Response
*/
public function login()
{
$potential_user = \Pinom\Models\User::where('email', 'LIKE', \Input::has('email') ? \Input::get('email') : '')->first();
if (!is_null($potential_user) && trim($potential_user->password) == '') {
//echo "isnull password!";
$user = \Sentinel::findById($potential_user->id);
$password = ['password' => $potential_user->id . '.' . $potential_user->email];
$user = \Sentinel::update($user, $password);
$activation = \Activation::create($user);
$activation = \Activation::complete($user, $activation->code);
}
$credentials = ['email' => \Input::has('email') ? \Input::get('email') : '', 'password' => \Input::has('passw') ? \Input::get('passw') : ''];
//echo '<pre>';
//return redirect('/');
$user = \Sentinel::authenticate($credentials);
//print_R($user);
if ($user = \Sentinel::check()) {
return redirect('/login');
} else {
return redirect('/login');
}
}
示例14: array
return $instance->active ? '✓' : '-';
})]);
return $display;
})->create(function ($id) {
$form = AdminForm::form();
$form->ajax_validation(true);
$form->horizontal(true);
$form->label_size('col-sm-offset-4 col-sm-1');
$form->field_size('col-sm-3');
$form->items([FormItem::text('title', 'Title')->validationRules('unique:pages,title,' . $id), FormItem::text('alias', 'Alias')->validationRules('unique:pages,alias,' . $id . ',id,context,' . Request::get('context', '')), FormItem::select('context', 'Context')->enum(config('jetcms.models.context')), FormItem::bsselect('user_id', 'User')->model('App\\User')->display('email|id')->defaultValue(Sentinel::check()->id)->nullable()]);
return $form;
})->edit(function ($id) {
$model = App\Page::find($id);
$form = AdminForm::tabbed();
$form->ajax_validation(true);
$form->items(array('Main' => array(FormItem::columns()->columns([[FormItem::text('title', 'Title')->validationRules('unique:pages,title,' . $id), FormItem::text('alias', 'Alias')->validationRules('unique:pages,alias,' . $id . ',id,context,' . Request::get('context', '')), FormItem::textarea('description', 'Description'), FormItem::chosen('tag', 'Tag')->model('App\\Tag')->display('lable')->multi(true)->nullable(), FormItem::icheckbox('active')->label('Active')->skin('flat')], [FormItem::bsselect('menu_id', 'Menu id')->options(App\Menu::getNestedList('level_lable'))->disableSort()->nullable(), FormItem::select('context', 'Context')->enum(config('jetcms.models.context')), FormItem::select('template', 'Template')->enum(config('jetcms.models.template.' . $model->context, []))->nullable()->disableSort(), FormItem::select('policies', 'Policies')->enum(config('jetcms.models.policies.' . $model->context, []))->nullable()->disableSort(), FormItem::bsselect('user_id', 'User')->model('App\\User')->display('email|id')->defaultValue(Sentinel::check()->id)->nullable(), FormItem::image('image', 'Image')]]), FormItem::images('gallery', 'Gallery')), 'Content' => [FormItem::ckeditor('content', 'Text')], 'Fields' => value(function () use($id, $model) {
//if (!$model) {return array();}
return [FormItem::custom()->display(function ($instance) use($model) {
$str = null;
foreach (config('jetcms.models.fields.' . $instance->context, array()) as $val) {
$type = $val['type'];
$input = FormItem::$type('field_array.' . $val['name'] . '', $val['lable']);
$input->defaultValue($instance->field($val['name']));
$str .= $input;
}
return $str;
})->callback(function ($instance) {
$instance->fieldArray = Request::input('field_array');
})];
}), 'Action' => [FormItem::custom()->display(function ($instance) {
$str = null;
示例15:
<?php
\Admin::model('App\\Product')->title('Products')->alias('products')->display(function () {
$display = AdminDisplay::datatablesAsync();
$display->columns([Column::checkbox(), Column::string('id')->label('#'), Column::string('title')->label('Загаловок'), Column::string('active_status')->label('Статус'), Column::string('publish')->label('Опубликован')]);
return $display;
})->createAndEdit(function () {
$form = AdminForm::tabbed();
$form->items(['Main' => [FormItem::columns()->columns([[FormItem::text('title', 'Загаловок')->required()->unique(), FormItem::textarea('description', 'Описание')->required(), FormItem::timestamp('publish', 'Дата и время публикации')->defaultValue(Carbon\Carbon::now()), FormItem::icheckbox('active', 'Статус')->defaultValue(true), FormItem::text('rest', 'Остаток'), FormItem::text('price', 'Цена')], [FormItem::text('sort', 'сортировка'), FormItem::bsselect('user_id', 'Пользователь')->model('App\\User')->defaultValue(Sentinel::check()->id)->display('email'), FormItem::bsselect('catalog_id', 'Категоря')->model('App\\Catalog')->display('level_label')->disableSort()->required()]])], 'content' => [FormItem::markdown('content', 'Контент')], 'images' => [FormItem::images('gallery', 'Картинки')], 'files' => [FormItem::view('suroviy.soa_addon::admin.elfinder')]]);
return $form;
});