2020-05-13 21:47:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
2020-06-27 23:46:49 +00:00
|
|
|
use App\Facades\UUID;
|
2020-05-13 21:47:51 +00:00
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
|
|
|
|
class UsernameUUID
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Converts a Minecraft username found in the request body to a UUID
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
|
|
|
$input = $request->all();
|
|
|
|
if (isset($input['uuid']))
|
|
|
|
{
|
|
|
|
$username = $input['uuid'];
|
2020-06-27 23:46:49 +00:00
|
|
|
$input['uuid'] = UUID::toUUID($username);
|
2020-05-13 21:47:51 +00:00
|
|
|
|
|
|
|
$request->replace($input);
|
|
|
|
}
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|