AuthAPI, favicon tweak
Got the first part of the API working, which checks to see if there is a valid session active to set up requests also some small changes to get the favicon working, yeah, yeah, but it's cool looking...
This commit is contained in:
parent
f7c9558da2
commit
166e19a656
4 changed files with 40 additions and 0 deletions
36
app/Http/Controllers/API/AuthAPIController.php
Normal file
36
app/Http/Controllers/API/AuthAPIController.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Services\AuthService;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class AuthAPIController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
AuthService $authService
|
||||||
|
) {
|
||||||
|
$this->auth = $authService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function status(Request $request)
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
$data = json_decode($request->getContent());
|
||||||
|
if ($this->auth::status()) {
|
||||||
|
$result = [
|
||||||
|
'message' => 'Authorized',
|
||||||
|
'type' => 'apiUseAuthorized',
|
||||||
|
'token' => session('token'),
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$result = [
|
||||||
|
'message' => 'Not Authorized',
|
||||||
|
'type' => 'apiUseNotAuthorized',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($result);
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@
|
||||||
@yield('title')
|
@yield('title')
|
||||||
</title>
|
</title>
|
||||||
<link rel="stylesheet" type="text/css" href="/assets/css/dash/start.css">
|
<link rel="stylesheet" type="text/css" href="/assets/css/dash/start.css">
|
||||||
|
<link rel="shortcut icon" href="/favicon.png" type="image/x-icon">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use App\Http\Controllers\API\AuthAPIController;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -14,6 +15,8 @@ use Illuminate\Support\Facades\Route;
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Route::get("/v1/status", [AuthAPIController::class, 'status']);
|
||||||
|
|
||||||
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
|
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
|
||||||
return $request->user();
|
return $request->user();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue