mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-17 22:03:44 +02:00
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:
@@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user