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


PHP Sentinel::findByCredentials方法代码示例

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


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

示例1: doLogin

 public function doLogin(Request $request)
 {
     // dd($request);
     //get the users credentials
     $credentials = ['login' => $request->email];
     //check if there is a match for the email and pword provided
     $user = \Sentinel::findByCredentials($credentials);
     //if there is no match redirect to login page ith input
     if (is_null($user)) {
         // dd($user);
         session()->flash('flash_message', 'Login failure.');
         session()->flash('flash_message_important', true);
         return \Redirect::back()->withInput();
     }
     //attempt to login
     $login = isset($request->remember_me) && $request->remember_me == 1 ? $user = \Sentinel::login($user) : ($user = \Sentinel::login($user));
     // store user info in session
     $user = \Sentinel::getUser();
     \Session::put('user', $user);
     //store user's role in session
     $roles = [];
     foreach ($user->roles as $role) {
         $roles[] = $role;
     }
     \Session::put('roles', $roles);
     //store session and term info in session
     $term_info = DB::table('current_term')->orderBy('created_at', 'desc')->first();
     if (null !== $term_info) {
         \Session::put(['current_session' => $term_info->session, 'current_term' => $term_info->term]);
     }
     return \Redirect::intended();
 }
开发者ID:umahatokula,项目名称:academia,代码行数:32,代码来源:loginController.php

示例2: 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

示例3: remind

 /**
  * Handle posting of the form for the forgot password.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function remind()
 {
     $email = Input::get('email');
     if ($user = Sentinel::findByCredentials(compact('email'))) {
         $reminder = Reminder::exists($user) ?: Reminder::create($user);
         $code = $reminder->code;
         $sent = Mail::send('sentinel.emails.reminder', compact('user', 'code'), function ($m) use($user) {
             $m->to($user->email)->subject('Reset your account password.');
         });
     }
     return Redirect::route('user.remember')->withSuccess('An email was sent with instructions on how to reset your password.');
 }
开发者ID:ryanrobertsname,项目名称:giftertipster.com,代码行数:17,代码来源:RemindersController.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('role_users')->delete();
     $userUser = Sentinel::findByCredentials(['login' => 'user@user.com']);
     $adminUser = Sentinel::findByCredentials(['login' => 'admin@admin.com']);
     $userRole = Sentinel::findRoleByName('Users');
     $adminRole = Sentinel::findRoleByName('Admins');
     // Assign the roles to the users
     $userRole->users()->attach($userUser);
     $adminRole->users()->attach($adminUser);
     $this->command->info('Users assigned to roles seeded!');
 }
开发者ID:kasirye,项目名称:basic-auth-sentinel,代码行数:17,代码来源:SentinelUserRoleSeeder.php

示例5: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     # User Seeder
     Sentinel::registerAndActivate(['email' => 'user@user.com', 'password' => 'user123', 'first_name' => 'علی', 'last_name' => 'شفیعی', 'address1' => 'مجیدیه شمالی نرسیده به میدان سرباز کوچه شهید داوود علی بخشی پلاک 55 طبقه اول', 'address2' => 'سعادت آباد، کوی فراز شماره 86 بلوک 4 طبقه دوم واحد 4', 'address3' => 'سعدی جنوبی کوچه بانک تجارت پلاک 3 طبقه دوم']);
     Sentinel::registerAndActivate(['email' => 'admin@admin.com', 'password' => 'admin123', 'first_name' => 'مجید', 'last_name' => 'نورعلی', 'address1' => 'مجیدیه شمالی نرسیده به میدان سرباز کوچه شهید داوود علی بخشی پلاک 55 طبقه اول', 'address2' => 'سعادت آباد، کوی فراز شماره 86 بلوک 4 طبقه دوم واحد 4', 'address3' => 'سعدی جنوبی کوچه بانک تجارت پلاک 3 طبقه دوم']);
     $this->command->info('Users seeded!');
     # Role Seeder
     DB::table('roles')->delete();
     Sentinel::getRoleRepository()->createModel()->create(['name' => 'users', 'slug' => 'users']);
     Sentinel::getRoleRepository()->createModel()->create(['name' => 'admins', 'slug' => 'admins']);
     $this->command->info('Roles seeded!');
     # User Role Seeder
     DB::table('role_users')->delete();
     $user = Sentinel::findByCredentials(['login' => 'user@user.com']);
     $admin = Sentinel::findByCredentials(['login' => 'admin@admin.com']);
     $userRole = Sentinel::findRoleByName('users');
     $adminRole = Sentinel::findRoleByName('admins');
     $userRole->users()->attach($user);
     $adminRole->users()->attach($admin);
     $this->command->info('Users assigned to roles seeded!');
     # Categories Table Seeder
     DB::table('cats')->delete();
     DB::table('cats')->insert([['title' => 'کاغذ'], ['title' => 'زینک'], ['title' => 'مرکب']]);
     $this->command->info('Categories Table Seeded.');
     # Orders Table Seeder
     DB::table('orders')->delete();
     DB::table('orders')->insert([['user_id' => '2', 'sum' => '208600', 'address' => 'سعدی جنوبی کوچه بانک تجارت پلاک 3 طبقه دوم', 'status' => '1'], ['user_id' => '2', 'sum' => '145500', 'address' => 'مجیدیه شمالی نرسیده به میدان سرباز کوچه شهید داوود علی بخشی پلاک 55 طبقه اول', 'status' => '0'], ['user_id' => '2', 'sum' => '650000', 'address' => 'سعدی جنوبی کوچه بانک تجارت پلاک 3 طبقه دوم', 'status' => '1']]);
     $this->command->info('Orders Table Seeded.');
     # Products Table Seeder
     DB::table('products')->delete();
     DB::table('products')->insert([['name' => 'کاغذ A4 Copymax', 'des' => 'کاغذ A4 Copymax کاغذ A4 Copymax کاغذ A4 Copymax', 'cat_id' => 1, 'size' => '210x297', 'weight' => 80, 'pic' => 'copimax.jpg', 'active' => 1], ['name' => 'کاغذ A4 DoubleA', 'des' => 'کاغذ A4 DoubleA کاغذ A4 DoubleA کاغذ A4 DoubleA', 'cat_id' => 1, 'size' => '210x297', 'weight' => 80, 'pic' => 'doublea.jpg', 'active' => 1], ['name' => 'زینک GTO', 'des' => 'زینک GTO زینک GTO زینک GTO', 'cat_id' => 2, 'size' => '326x256', 'weight' => 213, 'pic' => 'zinc1.jpg', 'active' => 1], ['name' => 'کاغذ JKcmax', 'des' => 'کاغذ JKcmax کاغذ JKcmax کاغذ JKcmax', 'cat_id' => 1, 'size' => '210x297', 'weight' => 80, 'pic' => 'jkcmax.jpg', 'active' => 1], ['name' => 'زینک دو ورقی', 'des' => 'زینک دو ورقی زینک دو ورقی زینک دو ورقی', 'cat_id' => 2, 'size' => '544x456', 'weight' => 253, 'pic' => 'zinc2.jpg', 'active' => 1], ['name' => 'زینگ دو و نیم ورقی اسپید', 'des' => 'زینگ دو و نیم ورقی اسپید زینگ دو و نیم ورقی اسپید زینگ دو و نیم ورقی اسپید', 'cat_id' => 2, 'size' => '700x500', 'weight' => 315, 'pic' => 'zinc3.jpg', 'active' => 1], ['name' => 'زینگ چهار و نیم ورقی', 'des' => 'زینگ چهار و نیم ورقی زینگ چهار و نیم ورقی زینگ چهار و نیم ورقی', 'cat_id' => 2, 'size' => '700x500', 'weight' => 315, 'pic' => 'zinc4.jpg', 'active' => 1], ['name' => 'مرکب Huaguang', 'des' => 'مرکب Huaguang مرکب Huaguang مرکب Huaguang', 'cat_id' => 3, 'size' => '454', 'weight' => 4545, 'pic' => 'uv1.jpg', 'active' => 1], ['name' => 'مرکب Huaguang 1', 'des' => 'مرکب Huaguang 1 مرکب Huaguang 1 مرکب Huaguang 1', 'cat_id' => 3, 'size' => '4564', 'weight' => 345, 'pic' => 'uv2.jpg', 'active' => 1], ['name' => 'مرکب چاپ', 'des' => 'مرکب چاپ مرکب چاپ مرکب چاپ', 'cat_id' => 3, 'size' => '4564', 'weight' => 345, 'pic' => 'uv3.jpg', 'active' => 1]]);
     $this->command->info('Products Seeded.');
     # Units Table Seeder
     DB::table('units')->delete();
     DB::table('units')->insert([['title' => 'بسته'], ['title' => 'کارتن'], ['title' => 'بند'], ['title' => 'گالن'], ['title' => 'جعبه'], ['title' => 'پالت']]);
     $this->command->info('Units Table Seeded.');
     # Unit Cats Table Seeder
     DB::table('unit_cats')->delete();
     DB::table('unit_cats')->insert([['cat_id' => '1', 'unit_id' => '1'], ['cat_id' => '1', 'unit_id' => '2'], ['cat_id' => '2', 'unit_id' => '1'], ['cat_id' => '3', 'unit_id' => '4'], ['cat_id' => '2', 'unit_id' => '6'], ['cat_id' => '3', 'unit_id' => '5']]);
     $this->command->info('Unit_Cats Table Seeded.');
     # Price Table Seeder
     DB::table('prices')->delete();
     DB::table('prices')->insert([['product_id' => '1', 'unit_id' => '1', 'price' => '100000'], ['product_id' => '1', 'unit_id' => '2', 'price' => '110000'], ['product_id' => '2', 'unit_id' => '1', 'price' => '200000'], ['product_id' => '2', 'unit_id' => '2', 'price' => '210000'], ['product_id' => '3', 'unit_id' => '1', 'price' => '300000'], ['product_id' => '3', 'unit_id' => '6', 'price' => '333000'], ['product_id' => '4', 'unit_id' => '1', 'price' => '400000'], ['product_id' => '4', 'unit_id' => '2', 'price' => '410000'], ['product_id' => '5', 'unit_id' => '1', 'price' => '500000'], ['product_id' => '5', 'unit_id' => '6', 'price' => '555000'], ['product_id' => '6', 'unit_id' => '1', 'price' => '600000'], ['product_id' => '6', 'unit_id' => '6', 'price' => '666000'], ['product_id' => '7', 'unit_id' => '1', 'price' => '700000'], ['product_id' => '7', 'unit_id' => '6', 'price' => '777000'], ['product_id' => '8', 'unit_id' => '4', 'price' => '800000'], ['product_id' => '8', 'unit_id' => '5', 'price' => '888000'], ['product_id' => '9', 'unit_id' => '4', 'price' => '900000'], ['product_id' => '9', 'unit_id' => '5', 'price' => '999000'], ['product_id' => '10', 'unit_id' => '4', 'price' => '910000'], ['product_id' => '10', 'unit_id' => '5', 'price' => '919000']]);
     $this->command->info('Prices Table Seeded.');
 }
开发者ID:majid-n,项目名称:printkala,代码行数:50,代码来源:DatabaseSeeder.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // dd($request->assign_permission);
     //array to hold final permission values
     $array_of_permissions = Helper::prepPermissions($request->assign_permission, 'true');
     //create new role
     $role = \Sentinel::getRoleRepository()->createModel()->create(['name' => $request->role, 'slug' => Helper::makeSlug($request->role)]);
     //retreive id of last inserted role
     $role_id = $role->id;
     $role = \Sentinel::findRoleById($role_id);
     //assign permissions to role
     $role->permissions = $array_of_permissions;
     $role->save();
     //assign newly created role to coder
     $credentials = ['login' => 'umahatokula@ovalsofttechnologies.com'];
     $user = \Sentinel::findByCredentials($credentials);
     $role->users()->attach($user);
     return \Redirect::to('settings/roles');
 }
开发者ID:umahatokula,项目名称:academia,代码行数:25,代码来源:rolesController.php

示例7: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('roles')->delete();
     DB::table('users')->delete();
     DB::table('role_users')->delete();
     $roles = ['administradores' => ['name' => 'Administradores', 'slug' => 'administradores', 'permissions' => ['admin.system' => true]], 'invitados' => ['name' => 'Invitados', 'slug' => 'invitados']];
     foreach ($roles as $role) {
         Sentinel::getRoleRepository()->createModel()->fill($role)->save();
     }
     $this->command->info('Roles seeded!');
     $users = [['email' => 'administrador@jenion.com.ve', 'password' => '12345678', 'first_name' => 'Administrador', 'last_name' => 'Jenion', 'nickname' => 'admjenion'], ['email' => 'invitado@jenion.com.ve', 'password' => '12345678', 'first_name' => 'Invitado', 'last_name' => 'Jenion', 'nickname' => 'invjenion']];
     foreach ($users as $user) {
         Sentinel::registerAndActivate($user);
     }
     $this->command->info('Users seeded!');
     $admUser = Sentinel::findByCredentials(['login' => 'administrador@jenion.com.ve']);
     $invUser = Sentinel::findByCredentials(['login' => 'invitado@jenion.com.ve']);
     $invGroup = Sentinel::findRoleByName('Invitados');
     $admGroup = Sentinel::findRoleByName('Administradores');
     // Assign the groups to the users
     $invGroup->users()->attach($invUser);
     $admGroup->users()->attach($admUser);
     $this->command->info('Users assigned to role seeded!');
 }
开发者ID:reysmerwvr,项目名称:jenion,代码行数:29,代码来源:UsersTableSeeder.php

示例8: function

Route::get('deactivate', function () {
    $user = Sentinel::check();
    Activation::remove($user);
    return Redirect::back()->withSuccess('Account deactivated.');
});
Route::get('reset', function () {
    return View::make('sentinel.reset.begin');
});
Route::post('reset', function () {
    $rules = ['email' => 'required|email'];
    $validator = Validator::make(Input::get(), $rules);
    if ($validator->fails()) {
        return Redirect::back()->withInput()->withErrors($validator);
    }
    $email = Input::get('email');
    $user = Sentinel::findByCredentials(compact('email'));
    if (!$user) {
        return Redirect::back()->withInput()->withErrors('No user with that email address belongs in our system.');
    }
    // $reminder = Reminder::exists($user) ?: Reminder::create($user);
    // $code = $reminder->code;
    // $sent = Mail::send('sentinel.emails.reminder', compact('user', 'code'), function($m) use ($user)
    // {
    //  $m->to($user->email)->subject('Reset your account password.');
    // });
    // if ($sent === 0)
    // {
    //  return Redirect::to('register')
    //      ->withErrors('Failed to send reset password email.');
    // }
    return Redirect::to('wait');
开发者ID:abada,项目名称:laravel_tasks,代码行数:31,代码来源:routes.php


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