Skip to content

Commit

Permalink
Merge pull request #93 from sfelix-martins/fix-actingas
Browse files Browse the repository at this point in the history
Fixed actingAs to return 200 instead of 201
  • Loading branch information
sfelix-martins authored Jun 15, 2019
2 parents ff59417 + 2cc1838 commit 35c5676
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/.idea
/.phpintel
/.vscode
.composer.lock
composer.lock
.phpunit.result.cache
2 changes: 1 addition & 1 deletion src/Guards/GuardChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function getAuthGuards(Request $request)
public static function getGuardsProviders($guards)
{
return collect($guards)->mapWithKeys(function ($guard) {
return [GuardChecker::defaultGuardProvider($guard) => $guard];
return [self::defaultGuardProvider($guard) => $guard];
});
}

Expand Down
8 changes: 7 additions & 1 deletion src/PassportMultiauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PassportMultiauth
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param array $scopes
* @return void
* @return \Illuminate\Contracts\Auth\Authenticatable
* @throws Exception
*/
public static function actingAs($user, $scopes = [])
Expand All @@ -35,11 +35,17 @@ public static function actingAs($user, $scopes = [])

$user->withAccessToken($token);

if (isset($user->wasRecentlyCreated) && $user->wasRecentlyCreated) {
$user->wasRecentlyCreated = false;
}

$guard = AuthConfigHelper::getUserGuard($user);

app('auth')->guard($guard)->setUser($user);

app('auth')->shouldUse($guard);

return $user;
}

/**
Expand Down

0 comments on commit 35c5676

Please sign in to comment.