moved login/logout to dash; removed AuthController
Member authorization got moved to the member repo class a long time ago, so AuthController was a leftover when that process was handled by something else moved dashboard login/logout to DashController and got rid of AuthController as it's not necessary anymore
This commit is contained in:
parent
59ab2e1536
commit
5300c91058
4 changed files with 46 additions and 95 deletions
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use App\Interfaces\MemberRepositoryInterface;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
protected $member;
|
||||
|
||||
public function __construct(
|
||||
MemberRepositoryInterface $memberRepository
|
||||
) {
|
||||
$this->member = $memberRepository;
|
||||
}
|
||||
|
||||
public function enter(Request $request): Response
|
||||
{
|
||||
$token = csrf_token();
|
||||
|
||||
$credentials = $request->validate([
|
||||
'handle' => ['required'],
|
||||
'password' => ['required'],
|
||||
]);
|
||||
|
||||
if ($credentials) {
|
||||
$result = $this->member->auth($request);
|
||||
if ($result['status']) {
|
||||
//$request->session()->regenerate();
|
||||
return redirect()->intended('dashboard/start');
|
||||
} else {
|
||||
return back()->withErrors([
|
||||
'error' => $result['message'],
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
return back()->withErrors([
|
||||
'error' => 'Nope. Check your crendtials, champ',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function exit(Request $request): Response
|
||||
{
|
||||
session()->flush();
|
||||
return redirect()->intended('dashboard');
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use App\Interfaces\PageRepositoryInterface;
|
||||
use App\Interfaces\MemberRepositoryInterface;
|
||||
use App\Services\Assets\FileUploadService;
|
||||
|
@ -29,12 +30,9 @@ class DashController extends Controller
|
|||
|
||||
public function start()
|
||||
{
|
||||
$result = [];
|
||||
|
||||
if ($this->member::status()) {
|
||||
$result = [];
|
||||
$result = $this->pages->getGroup(1, 4);
|
||||
}
|
||||
if ($this->member::status()) {
|
||||
return view('back.start', [
|
||||
"status" => $this->member::status(),
|
||||
"result" => $result,
|
||||
|
@ -48,9 +46,42 @@ class DashController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function exit()
|
||||
{
|
||||
session()->flush();
|
||||
return redirect()->intended('dashboard');
|
||||
}
|
||||
|
||||
//---
|
||||
// POST
|
||||
//---
|
||||
public function enter(Request $request): Response
|
||||
{
|
||||
$token = csrf_token();
|
||||
|
||||
$credentials = $request->validate([
|
||||
'handle' => ['required'],
|
||||
'password' => ['required'],
|
||||
]);
|
||||
|
||||
if ($credentials) {
|
||||
$result = $this->member->auth($request);
|
||||
if ($result['status']) {
|
||||
//$request->session()->regenerate();
|
||||
return redirect()->intended('dashboard');
|
||||
//return $this->start();
|
||||
} else {
|
||||
return back()->withErrors([
|
||||
'error' => $result['message'],
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
return back()->withErrors([
|
||||
'error' => 'Nope. Check your crendtials, champ',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function uploads(Request $request)
|
||||
{
|
||||
$result = $result = $this->upload->handleFile($request);
|
||||
|
@ -69,30 +100,4 @@ class DashController extends Controller
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//---
|
||||
// PUT
|
||||
//---
|
||||
|
||||
//---
|
||||
// AUTH
|
||||
//---
|
||||
|
||||
public function login()
|
||||
{
|
||||
if ($this->member::status()) {
|
||||
return redirect('dashboard/start');
|
||||
} else {
|
||||
return view('back.login', [
|
||||
"status" => $this->member::status(),
|
||||
"title" => "Hi!"
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
session()->flush();
|
||||
return redirect()->intended('dashboard');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<section class="login">
|
||||
<div>
|
||||
<img alt="fipamo logo" id="the-logo" class="logo-medium" src="/assets/images/global/fipamo-logo-secondary.svg"/>
|
||||
<img alt="fipamo logo" id="the-logo" class="logo-medium" src="/assets/images/global/fipamo-logo-secondary.svg" />
|
||||
</div>
|
||||
<form action="/login" method="post" enctype="multipart/form-data">
|
||||
<label class="inline">handle</label><input class="input-light" type="text" name="handle" class="inline" placeholder="Handle" required/>
|
||||
<label class="inline">password</label><input class="input-light" type="password" name="password" class="inline" placeholder="Password" required/>
|
||||
<form action="/dashboard/login" method="post" enctype="multipart/form-data">
|
||||
<label class="inline">handle</label><input class="input-light" type="text" name="handle" class="inline" placeholder="Handle" required />
|
||||
<label class="inline">password</label><input class="input-light" type="password" name="password" class="inline" placeholder="Password" required />
|
||||
@if($errors->any())
|
||||
<input type="submit" value="{{$errors->first()}}" name="submit_button">
|
||||
@else
|
||||
|
@ -12,4 +12,4 @@
|
|||
@endif
|
||||
@csrf
|
||||
</form>
|
||||
</section>
|
||||
</section>
|
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\FrontController;
|
||||
use App\Http\Controllers\PageController;
|
||||
use App\Http\Controllers\DashController;
|
||||
use App\Http\Controllers\SettingsController;
|
||||
use App\Http\Controllers\AuthController;
|
||||
use App\Http\Controllers\ThemeController;
|
||||
use App\Http\Controllers\SystemMailController;
|
||||
use App\Http\Middleware\VerifyCsrfToken;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
//Frontend
|
||||
Route::prefix('/')
|
||||
->controller(FrontController::class)
|
||||
->group(function () {
|
||||
|
@ -18,17 +17,14 @@ Route::prefix('/')
|
|||
Route::post("/init/{task}", 'init');
|
||||
});
|
||||
|
||||
//login stuff
|
||||
Route::post("/login", [AuthController::class, 'enter']);
|
||||
|
||||
//Dashboard
|
||||
Route::prefix('dashboard')
|
||||
->middleware('member.check')
|
||||
->controller(DashController::class)
|
||||
->group(function () {
|
||||
Route::get("/", 'login')->withoutMiddleware('member.check');
|
||||
Route::get("/start", 'start');
|
||||
Route::get("/logout", 'logout');
|
||||
Route::post("/login", 'enter')->withoutMiddleware('member.check');
|
||||
Route::get("/", 'start')->withoutMiddleware('member.check');
|
||||
Route::get("/logout", 'exit');
|
||||
Route::post("/uploads", 'uploads');
|
||||
})->name('dashboard');
|
||||
|
||||
|
@ -64,7 +60,7 @@ Route::prefix('dashboard/mailer')
|
|||
Route::post("/", 'sendNotify');
|
||||
});
|
||||
|
||||
//themekit
|
||||
//Themekit
|
||||
Route::prefix('dashboard/themekit')
|
||||
->middleware('member.check')
|
||||
->controller(ThemeController::class)
|
||||
|
|
Loading…
Add table
Reference in a new issue