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


PHP Sentinel类代码示例

本文整理汇总了PHP中Sentinel的典型用法代码示例。如果您正苦于以下问题:PHP Sentinel类的具体用法?PHP Sentinel怎么用?PHP Sentinel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //get currrnt user
     $user = \Sentinel::getUser();
     if ($user->inRole('coder')) {
         return $next($request);
     } else {
         return \Redirect::back()->with('message', 'You do not have the permission to access this page');
     }
 }
开发者ID:umahatokula,项目名称:academia,代码行数:17,代码来源:Admin.php

示例2: forgot

 public function forgot()
 {
     if (!Sentinel::check()) {
         $this->redirect('/', false);
     }
     $this->render('login/forgot');
 }
开发者ID:EpykOS,项目名称:epykosLittleHelper,代码行数:7,代码来源:login.controller.php

示例3: run

 public function run()
 {
     // we create the admin role
     $admin = Sentinel::getRoleRepository()->createModel()->create(['slug' => 'admin', 'position' => 1]);
     // we translate the translatable fields
     $admin->translateOrNew('fr')->name = 'Administrateur';
     $admin->translateOrNew('en')->name = 'Administrator';
     // we give all permissions to the admin role
     $permissions = [];
     foreach (array_dot(config('permissions')) as $permission => $value) {
         $permissions[$permission] = true;
     }
     $admin->permissions = $permissions;
     // we save the changes
     $admin->save();
     // we create the moderator role
     $mod = Sentinel::getRoleRepository()->createModel()->create(['slug' => 'moderator', 'position' => 2, 'permissions' => ['users.list' => true, 'users.view' => true, 'home.page.view' => true, 'home.slides.view' => true, 'news.page.view' => true, 'news.create' => true, 'news.view' => true, 'news.update' => true, 'schedules' => true, 'schedules.page.view' => true, 'schedules.create' => true, 'schedules.view' => true, 'schedules.update' => true, 'schedules.delete' => true, 'registration.page.view' => true, 'registration.prices.create' => true, 'registration.prices.view' => true, 'registration.prices.update' => true, 'registration.prices.delete' => true, 'partners.list' => true, 'partners.view' => true]]);
     // we translate the translatable fields
     $mod->translateOrNew('fr')->name = 'Modérateur';
     $mod->translateOrNew('en')->name = 'Moderator';
     $mod->save();
     // we create the moderator role
     $mod = Sentinel::getRoleRepository()->createModel()->create(['slug' => 'coach', 'position' => 3, 'permissions' => ['users.list' => true, 'users.view' => true, 'home.page.view' => true, 'home.slides.view' => true, 'news.page.view' => true, 'news.create' => true, 'news.view' => true, 'news.update' => true, 'schedules' => true, 'schedules.page.view' => true, 'schedules.create' => true, 'schedules.view' => true, 'schedules.update' => true, 'schedules.delete' => true, 'registration.page.view' => true, 'registration.prices.create' => true, 'registration.prices.view' => true, 'registration.prices.update' => true, 'registration.prices.delete' => true, 'partners.list' => true, 'partners.view' => true]]);
     // we translate the translatable fields
     $mod->translateOrNew('fr')->name = 'Coach';
     $mod->translateOrNew('en')->name = 'Coach';
     $mod->save();
     // we create the user role
     $member = Sentinel::getRoleRepository()->createModel()->create(['slug' => 'user', 'position' => 4]);
     // we translate the translatable fields
     $member->translateOrNew('fr')->name = 'Utilisateur';
     $member->translateOrNew('en')->name = 'User';
     $member->save();
 }
开发者ID:Okipa,项目名称:una.app,代码行数:34,代码来源:RolesTableSeeder.php

示例4: __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();
 }
开发者ID:blare,项目名称:pinom,代码行数:28,代码来源:Controller.php

示例5: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $roleAdmin = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Admin', 'slug' => 'admin']);
     $roleUser = Sentinel::getRoleRepository()->createModel()->create(['name' => 'User', 'slug' => 'user']);
     $user = Sentinel::registerAndActivate(['email' => 'admin@admin.com', 'password' => 'admin']);
     $roleAdmin->users()->attach($user);
 }
开发者ID:hilmysyarif,项目名称:laravel-starter,代码行数:12,代码来源:UserTableSeeder.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $superuser = ['accommodation.store' => true, 'accommodation.show' => true, 'accommodation.update' => true, 'accommodation.destroy' => true, 'conference.store' => true, 'conference.show' => true, 'conference.update' => true, 'conference.destroy' => true, 'conference_manager.store' => true, 'conference_manager.show' => true, 'conference_manager.destroy' => true, 'conference_attendee.show' => true, 'conference_attendee.update' => true, 'conference_attendee.destroy' => true, 'conference_vehicle.store' => true, 'conference_vehicle.show' => true, 'conference_vehicle.update' => true, 'conference_vehicle.destroy' => true, 'event.status' => true, 'event.store' => true, 'event.show' => true, 'event.update' => true, 'event.destroy' => true, 'event_manager.store' => true, 'event_manager.show' => true, 'event_manager.destroy' => true, 'event_attendee.show' => true, 'event_attendee.update' => true, 'event_attendee.destroy' => true, 'event_vehicle.store' => true, 'event_vehicle.show' => true, 'event_vehicle.update' => true, 'event_vehicle.destroy' => true, 'item.store' => true, 'item.show' => true, 'item.update' => true, 'item.destroy' => true, 'profile.store' => true, 'profile.show' => true, 'profile.update' => true, 'profile.destroy' => true, 'role.store' => true, 'role.show' => true, 'role.update' => true, 'role.destroy' => true, 'room.store' => true, 'room.show' => true, 'room.update' => true, 'room.destroy' => true, 'user.show' => true, 'user.update' => true, 'user.destroy' => true, 'vehicle.store' => true, 'vehicle.show' => true, 'vehicle.update' => true, 'vehicle.destroy' => true];
     $conferenceManager = $superuser;
     $conferenceManager['role.store'] = false;
     $conferenceManager['role.show'] = false;
     $conferenceManager['role.update'] = false;
     $conferenceManager['role.destroy'] = false;
     $eventManager = $conferenceManager;
     $eventManager['accommodation.store'] = false;
     $eventManager['accommodation.update'] = false;
     $eventManager['accommodation.destroy'] = false;
     $eventManager['conference.store'] = false;
     $eventManager['conference.update'] = false;
     $eventManager['conference.destroy'] = false;
     $eventManager['conference_manager.store'] = false;
     $eventManager['conference_manager.destroy'] = false;
     $eventManager['conference_attendee.update'] = false;
     $eventManager['conference_attendee.destroy'] = false;
     $eventManager['conference_vehicle.store'] = false;
     $eventManager['conference_vehicle.update'] = false;
     $eventManager['conference_vehicle.destroy'] = false;
     $eventManager['item.store'] = false;
     $eventManager['item.update'] = false;
     $eventManager['item.destroy'] = false;
     $eventManager['room.store'] = false;
     $eventManager['room.update'] = false;
     $eventManager['room.destroy'] = false;
     $regularUser = ['accommodation.store' => false, 'accommodation.show' => false, 'accommodation.update' => false, 'accommodation.destroy' => false, 'conference.store' => false, 'conference.show' => true, 'conference.update' => false, 'conference.destroy' => false, 'conference_manager.store' => false, 'conference_manager.show' => false, 'conference_manager.destroy' => false, 'conference_attendee.show' => true, 'conference_attendee.update' => true, 'conference_attendee.destroy' => false, 'conference_vehicle.store' => false, 'conference_vehicle.show' => false, 'conference_vehicle.update' => false, 'conference_vehicle.destroy' => false, 'event.store' => false, 'event.show' => true, 'event.update' => false, 'event.destroy' => false, 'event_manager.store' => false, 'event_manager.show' => false, 'event_manager.destroy' => false, 'event_attendee.show' => true, 'event_attendee.update' => true, 'event_attendee.destroy' => false, 'event_vehicle.store' => false, 'event_vehicle.show' => false, 'event_vehicle.update' => false, 'event_vehicle.destroy' => false, 'item.store' => false, 'item.show' => false, 'item.update' => false, 'item.destroy' => false, 'profile.store' => true, 'profile.show' => true, 'profile.update' => true, 'profile.destroy' => true, 'role.store' => false, 'role.show' => false, 'role.update' => false, 'role.destroy' => false, 'room.store' => false, 'room.show' => false, 'room.update' => false, 'room.destroy' => false, 'user.show' => false, 'user.update' => false, 'user.destroy' => false, 'vehicle.store' => false, 'vehicle.show' => false, 'vehicle.update' => false, 'vehicle.destroy' => false];
     Sentinel::getRoleRepository()->createModel()->create(['slug' => 'system administrator', 'name' => 'System Administrator', 'permissions' => $superuser]);
     Sentinel::getRoleRepository()->createModel()->create(['slug' => 'conference manager', 'name' => 'Conference Manager', 'permissions' => $conferenceManager]);
     Sentinel::getRoleRepository()->createModel()->create(['slug' => 'event manager', 'name' => 'Event Manager', 'permissions' => $eventManager]);
     Sentinel::getRoleRepository()->createModel()->create(['slug' => 'regular user', 'name' => 'Regular User', 'permissions' => $regularUser]);
 }
开发者ID:vinlore,项目名称:huddle,代码行数:39,代码来源:RolesSeeder.php

示例7: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('users')->truncate();
     // Register a new user
     Sentinel::register(['email' => 'ccnaguit@piasi.com.ph', 'last_name' => 'Naguit', 'first_name' => 'Chester', 'password' => 'P@ssw0rd']);
     Sentinel::register(['email' => 'jvmiranda@piasi.com.ph', 'last_name' => 'Miranda', 'first_name' => 'Jefferson', 'password' => 'P@ssw0rd']);
 }
开发者ID:chesternaguit,项目名称:laravel5-project-starter,代码行数:12,代码来源:UserTableSeeder.php

示例8: 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);
 }
开发者ID:Okipa,项目名称:una.app,代码行数:14,代码来源:RedirectIfAuthenticated.php

示例9: 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);
 }
开发者ID:ramigit3D,项目名称:article,代码行数:15,代码来源:RedirectIfAuthenticated.php

示例10: logout

 public function logout()
 {
     \Session::flush();
     \Sentinel::logout();
     $data['title'] = 'Login';
     return \Redirect::to('/');
 }
开发者ID:umahatokula,项目名称:academia,代码行数:7,代码来源:loginController.php

示例11: __construct

 /**
  * Set the resource's model and validator.
  * @param ResourceServiceModelContract            $model           Resource's model
  * @param InputValidatorContract          $inputValidator  Resource's input validator
  */
 public function __construct(ResourceServiceModelContract $model, InputValidatorContract $inputValidator = null)
 {
     $this->model = $model;
     $this->inputValidator = $inputValidator;
     $this->user = new SentinelServiceUserAdapter(\Sentinel::getUser());
     // TODO: extract out
 }
开发者ID:skimia,项目名称:api-fusion,代码行数:12,代码来源:ResourceService.php

示例12: 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.');
 }
开发者ID:ryanrobertsname,项目名称:giftertipster.com,代码行数:13,代码来源:OAuthController.php

示例13: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('users')->delete();
     Sentinel::registerAndActivate(['email' => 'user@user.com', 'password' => 'sentineluser', 'first_name' => 'UserFirstName', 'last_name' => 'UserLastName']);
     Sentinel::registerAndActivate(['email' => 'admin@admin.com', 'password' => 'sentineladmin', 'first_name' => 'AdminFirstName', 'last_name' => 'AdminLastName']);
     $this->command->info('Users seeded!');
 }
开发者ID:kasirye,项目名称:basic-auth-sentinel,代码行数:12,代码来源:SentinelUserSeeder.php

示例14: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Hapus isi table users, groups, users_groups dan throttle
     DB::table('role_users')->delete();
     DB::table('roles')->delete();
     DB::table('users')->delete();
     DB::table('throttle')->delete();
     //create role administrator
     $role = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Administrators', 'slug' => 'administrators']);
     //create role regulars
     $role = Sentinel::getRoleRepository()->createModel()->create(['name' => 'Regulars', 'slug' => 'regulars']);
     //create user admin and activate
     $credentials = ['email' => 'admin@enter.id', 'password' => 'enter'];
     $user = Sentinel::registerAndActivate($credentials);
     //create user user and activate
     $credentials = ['email' => 'user@example.com', 'password' => 'enter'];
     $user = Sentinel::registerAndActivate($credentials);
     // assign user to a role
     $credentials = ['login' => 'admin@example.com'];
     $user = Sentinel::findByCredentials($credentials);
     //$user = Sentinel::findById(1);
     $role = Sentinel::findRoleByName('Administrators');
     $role->users()->attach($user);
     $credentials = ['login' => 'user@example.com'];
     $user = Sentinel::findByCredentials($credentials);
     //$user = Sentinel::findById(1);
     $role = Sentinel::findRoleByName('Regulars');
     $role->users()->attach($user);
 }
开发者ID:Fadli,项目名称:MiniERP,代码行数:34,代码来源:SentinelSeeder.php

示例15: handle

 public function handle($request, Closure $next)
 {
     if (!Sentinel::check()) {
         return Redirect::route('login');
     }
     return $next($request);
 }
开发者ID:benelang,项目名称:humiditybot,代码行数:7,代码来源:SentinelAuth.php


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