|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: Claudio Cardinale <[email protected]> |
|
5
|
|
|
* Date: 19/11/15 |
|
6
|
|
|
* Time: 22.48 |
|
7
|
|
|
* This program is free software; you can redistribute it and/or |
|
8
|
|
|
* modify it under the terms of the GNU General Public License |
|
9
|
|
|
* as published by the Free Software Foundation; either version 2 |
|
10
|
|
|
* of the License, or (at your option) any later version. |
|
11
|
|
|
* This program is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
* GNU General Public License for more details. |
|
15
|
|
|
* You should have received a copy of the GNU General Public License |
|
16
|
|
|
* along with this program; if not, write to the Free Software |
|
17
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace Tymon\JWTAuth\Support\testing; |
|
21
|
|
|
|
|
22
|
|
|
use \Illuminate\Contracts\Auth\Authenticatable; |
|
23
|
|
|
use Tymon\JWTAuth\Facades\JWTAuth; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Class ActingAs |
|
27
|
|
|
* @package Tymon\JWTAuth\Support\testing |
|
28
|
|
|
* @author Claudio Cardinale <[email protected]> |
|
29
|
|
|
* @copyright 2015 Claudio Cardinale |
|
30
|
|
|
* @version 1.0.0 |
|
31
|
|
|
*/ |
|
32
|
|
|
trait ActingAs |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* Set the currently logged in user for the application. |
|
36
|
|
|
* <strong>Caution:</strong> this disables the blacklist |
|
37
|
|
|
* |
|
38
|
|
|
* @param \Illuminate\Contracts\Auth\Authenticatable $user |
|
39
|
|
|
* @param string|null $driver only for the compatibility with the original method |
|
40
|
|
|
* @return $this |
|
41
|
|
|
*/ |
|
42
|
|
|
public function actingAs(Authenticatable $user, $driver = '') |
|
|
|
|
|
|
43
|
|
|
{ |
|
44
|
|
|
$manager = (JWTAuth::manager()); |
|
45
|
|
|
$manager->setBlacklistEnabled(false); |
|
46
|
|
|
JWTAuth::setUserModel($user); |
|
47
|
|
|
|
|
48
|
|
|
return $this; |
|
49
|
|
|
} |
|
50
|
|
|
} |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.