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:
ro 2024-03-07 12:04:52 -06:00
parent f7c9558da2
commit 166e19a656
No known key found for this signature in database
GPG key ID: 29B551CDBD4D3B50
4 changed files with 40 additions and 0 deletions

View 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);
}
}

View file

View file

@ -9,6 +9,7 @@
@yield('title')
</title>
<link rel="stylesheet" type="text/css" href="/assets/css/dash/start.css">
<link rel="shortcut icon" href="/favicon.png" type="image/x-icon">
</head>
<body>

View file

@ -2,6 +2,7 @@
use Illuminate\Http\Request;
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) {
return $request->user();
});