Push basis of new API key policy
Will need to revisit this another day when I’m fresh to figure out the best method to do this.
This commit is contained in:
parent
51204b8d9d
commit
db4df2bfa1
6 changed files with 104 additions and 19 deletions
|
@ -25,6 +25,7 @@
|
|||
namespace Pterodactyl\Providers;
|
||||
|
||||
use File;
|
||||
use Request;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class MacroServiceProvider extends ServiceProvider
|
||||
|
@ -48,5 +49,19 @@ class MacroServiceProvider extends ServiceProvider
|
|||
|
||||
return round($size, ($i < 2) ? 0 : $precision) . ' ' . $units[$i];
|
||||
});
|
||||
|
||||
Request::macro('apiKey', function () {
|
||||
if (! Request::bearerToken()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$parts = explode('.', Request::bearerToken());
|
||||
|
||||
if (count($parts) === 2) {
|
||||
return \Pterodactyl\Models\APIKey::where('public', $parts[0])->first();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue