Fix API auth issues (#9185)

* Fix API auth issues
Api access page now creates tokens with the correct ID.
Correctly creates users for legacy user tokens.
Fix Ldap comparison
Laravel Util class to make code easier to access/read

* More api access page fixes

* fix style
This commit is contained in:
Tony Murray
2018-09-11 22:36:52 -05:00
committed by GitHub
parent c3a24fe88f
commit e8cf6bb385
6 changed files with 168 additions and 90 deletions

View File

@@ -72,10 +72,17 @@ class TokenUserProvider extends LegacyUserProvider implements UserProvider
return $user;
}
// missing user for existing token, create it
$user_id = ApiToken::idFromToken($credentials['api_token']);
// missing user for existing token, create it assuming legacy auth_id
$api_token = ApiToken::where('token_hash', $credentials['api_token'])->first();
$user = $this->retrieveByLegacyId($api_token->user_id);
return $this->retrieveById($user_id);
// update token user_id
if ($user) {
$api_token->user_id = $user->user_id;
$api_token->save();
}
return $user;
}
/**