本文整理汇总了PHP中Sentry::setUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::setUser方法的具体用法?PHP Sentry::setUser怎么用?PHP Sentry::setUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentry
的用法示例。
在下文中一共展示了Sentry::setUser方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beAdmin
/**
* Impersonate an admin
*
*/
public function beAdmin()
{
$admin = Sentry::findUserByLogin('admin@admin.com');
Sentry::setUser($admin);
Session::put('userId', 1);
Session::put('email', 'admin@admin.com');
}
示例2: setUp
public function setUp()
{
Illuminate\Foundation\Testing\TestCase::setUp();
Artisan::call('migrate', array('--package' => 'cartalyst\\sentry'));
// Artisan::call('migrate');
Artisan::call('migrate', array('--package' => 'rtconner\\laravel-addresses'));
Artisan::call('db:seed', array('--class' => 'Conner\\Addresses\\DatabaseSeeder'));
$user = new \Cartalyst\Sentry\Users\Eloquent\User();
$user->id = 1;
\Sentry::setUser($user);
}
示例3: testBasicUserTypes
/**
* Test the two basic user types
*
*/
public function testBasicUserTypes()
{
$this->assertTrue(Sentry::getUser() == NULL, 'User should not be logged in initially.');
$admin = Sentry::findUserByLogin($this->adminEmail);
$this->assertTrue($admin != NULL, 'Admin account not found.');
$user = Sentry::findUserByLogin($this->userEmail);
$this->assertTrue($user != NULL, 'User account not found.');
Sentry::setUser($user);
$this->assertTrue(Sentry::check(), 'User not logged in.');
Sentry::setUser($admin);
$this->assertTrue(Sentry::check(), 'Admin not logged in.');
Sentry::logout();
}
示例4: testUpdatingUserWithAdditionalData
/**
* Update a user without referencing the username
*/
public function testUpdatingUserWithAdditionalData()
{
// Explicitly set the 'additional user fields'
app()['config']->set('sentinel.additional_user_fields', ['first_name' => 'alpha_spaces', 'last_name' => 'alpha_spaces']);
// Find the user we are going to update
$user = Sentry::findUserByLogin('user@user.com');
// Find the admin user we are going to impersonate
$admin = Sentry::findUserByLogin('admin@admin.com');
Sentry::setUser($admin);
// This is the code we are testing
$result = $this->repo->update(['id' => $user->id, 'first_name' => 'Irina', 'last_name' => 'Prozorova', 'email' => 'irina@prozorov.net']);
// Assertions
$this->assertInstanceOf('Sentinel\\Models\\User', $user);
$this->assertInstanceOf('Sentinel\\Models\\User', $result->getPayload()['user']);
$this->assertTrue($result->isSuccessful());
$testUser = DB::table('users')->where('id', $user->id)->where('first_name', 'Irina')->where('last_name', 'Prozorova')->where('email', 'irina@prozorov.net')->first();
$this->assertEquals('irina@prozorov.net', $testUser->email);
}
示例5: beAdmin
/**
* Impersonate an admin
*
*/
public function beAdmin()
{
$admin = Sentry::findUserByLogin($this->adminEmail);
Sentry::setUser($admin);
Session::put('userId', 1);
Session::put('email', $this->adminEmail);
}
示例6: beAdmin
/**
* Impersonate an admin
*
*/
public function beAdmin()
{
$admin = Sentry::findUserByLogin($this->adminEmail);
Sentry::setUser($admin);
}