Replaced Moment with Carbon #84
11 changed files with 115 additions and 71 deletions
|
@ -3,22 +3,24 @@
|
|||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\AuthService;
|
||||
use App\Interfaces\MemberRepositoryInterface;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AuthAPIController extends Controller
|
||||
{
|
||||
protected $member;
|
||||
|
||||
public function __construct(
|
||||
AuthService $authService
|
||||
MemberRepositoryInterface $memberRepo
|
||||
) {
|
||||
$this->auth = $authService;
|
||||
$this->member = $memberRepo;
|
||||
}
|
||||
|
||||
public function status(Request $request)
|
||||
{
|
||||
$result = [];
|
||||
$data = json_decode($request->getContent());
|
||||
if ($this->auth::status()) {
|
||||
if ($this->member::status()) {
|
||||
$result = [
|
||||
'message' => 'Authorized',
|
||||
'type' => 'apiUseAuthorized',
|
||||
|
|
|
@ -7,7 +7,7 @@ use Illuminate\Http\Request;
|
|||
use App\Services\SettingsService;
|
||||
use App\Services\RenderService;
|
||||
use App\Services\MaintenanceService;
|
||||
use App\Services\AuthService;
|
||||
use App\Interfaces\MemberRepositoryInterface;
|
||||
use App\Services\AssetService;
|
||||
|
||||
class SettingsAPIController extends Controller
|
||||
|
@ -15,20 +15,20 @@ class SettingsAPIController extends Controller
|
|||
protected $settings;
|
||||
protected $render;
|
||||
protected $mainteance;
|
||||
protected $auth;
|
||||
protected $member;
|
||||
protected $assets;
|
||||
|
||||
public function __construct(
|
||||
SettingsService $settingsService,
|
||||
RenderService $renderService,
|
||||
MaintenanceService $maintenanceService,
|
||||
AuthService $authService,
|
||||
MemberRepositoryInterface $memberRepo,
|
||||
AssetService $assetService
|
||||
) {
|
||||
$this->settings = $settingsService;
|
||||
$this->render = $renderService;
|
||||
$this->maintenance = $maintenanceService;
|
||||
$this->auth = $authService;
|
||||
$this->member = $memberRepo;
|
||||
$this->assets = $assetService;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ class SettingsAPIController extends Controller
|
|||
|
||||
public function downloadBackup(Request $request)
|
||||
{
|
||||
if ($this->auth::status()) {
|
||||
if ($this->member::status()) {
|
||||
$latest = $this->settings->getGlobal()['last_backup'];
|
||||
$file = 'backup-' . $latest . '.zip';
|
||||
return response()->download('../content/backups/' . $file, $file, ['Content-Type: application/zip']);
|
||||
|
|
|
@ -3,15 +3,17 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use App\Services\Data\AuthService;
|
||||
use App\Interfaces\MemberRepositoryInterface;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
protected $member;
|
||||
|
||||
public function __construct(
|
||||
AuthService $authService
|
||||
MemberRepositoryInterface $memberRepository
|
||||
) {
|
||||
$this->auth = $authService;
|
||||
$this->member = $memberRepository;
|
||||
}
|
||||
|
||||
public function enter(Request $request): Response
|
||||
|
@ -24,7 +26,7 @@ class AuthController extends Controller
|
|||
]);
|
||||
|
||||
if ($credentials) {
|
||||
$result = $this->auth->check($request);
|
||||
$result = $this->member->auth($request);
|
||||
if ($result['status']) {
|
||||
//$request->session()->regenerate();
|
||||
return redirect()->intended('dashboard/start');
|
||||
|
|
|
@ -3,25 +3,25 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Interfaces\PageRepositoryInterface;
|
||||
use App\Services\Data\AuthService;
|
||||
use App\Interfaces\MemberRepositoryInterface;
|
||||
use App\Services\Data\ThemeService;
|
||||
use App\Services\Data\SortingService;
|
||||
|
||||
class DashController extends Controller
|
||||
{
|
||||
protected PageRepositoryInterface $pages;
|
||||
protected AuthService $auth;
|
||||
protected MemberRepositoryInterface $member;
|
||||
protected ThemeService $themes;
|
||||
protected SortingService $sort;
|
||||
|
||||
public function __construct(
|
||||
PageRepositoryInterface $pageRepository,
|
||||
AuthService $authService,
|
||||
MemberRepositoryInterface $memberRepo,
|
||||
ThemeService $themeService,
|
||||
SortingService $sortingService
|
||||
) {
|
||||
$this->pages = $pageRepository;
|
||||
$this->auth = $authService;
|
||||
$this->member = $memberRepo;
|
||||
$this->themes = $themeService;
|
||||
$this->sort = $sortingService;
|
||||
}
|
||||
|
@ -54,11 +54,11 @@ class DashController extends Controller
|
|||
|
||||
public function login()
|
||||
{
|
||||
if ($this->auth::status()) {
|
||||
if ($this->member::status()) {
|
||||
return redirect('dashboard');
|
||||
} else {
|
||||
return view('back.login', [
|
||||
"status" => $this->auth::status(),
|
||||
"status" => $this->member::status(),
|
||||
"title" => "Hi!"
|
||||
]);
|
||||
}
|
||||
|
@ -67,11 +67,11 @@ class DashController extends Controller
|
|||
public function start()
|
||||
{
|
||||
$result = [];
|
||||
if ($this->auth::status()) {
|
||||
if ($this->member::status()) {
|
||||
$result = $this->pages->getGroup(1, 4);
|
||||
}
|
||||
return view('back.start', [
|
||||
"status" => $this->auth::status(),
|
||||
"status" => $this->member::status(),
|
||||
"result" => $result,
|
||||
"title" => "Start"
|
||||
]);
|
||||
|
@ -80,7 +80,7 @@ class DashController extends Controller
|
|||
public function book($pageFilter = 'all', $pageNum = 1)
|
||||
{
|
||||
$result = [];
|
||||
if ($this->auth::status()) {
|
||||
if ($this->member::status()) {
|
||||
$result = $this->pages->getGroup($pageNum, 4, $pageFilter);
|
||||
}
|
||||
return view('back.book', [
|
||||
|
@ -101,7 +101,7 @@ class DashController extends Controller
|
|||
$mode == 'edit' ? $views = $this->themes->getCustomViews($page['layout']) : $views[] = 'page';
|
||||
|
||||
return view('back.page', [
|
||||
"status" => $this->auth::status(),
|
||||
"status" => $this->member::status(),
|
||||
"mode" => $mode,
|
||||
"page" => $page,
|
||||
"views" => $views,
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace App\Http\Controllers;
|
|||
use App\Interfaces\PageRepositoryInterface;
|
||||
use App\Services\Assets\AssetService;
|
||||
use App\Services\Data\SettingsService;
|
||||
use App\Services\Data\AuthService;
|
||||
use App\Services\Data\SortingService;
|
||||
|
||||
use function _\find;
|
||||
|
@ -13,7 +12,6 @@ use function _\find;
|
|||
class FrontController extends Controller
|
||||
{
|
||||
protected $settings;
|
||||
protected $auth;
|
||||
protected PageRepositoryInterface $pages;
|
||||
protected AssetService $assets;
|
||||
protected SortingService $sort;
|
||||
|
@ -21,13 +19,11 @@ class FrontController extends Controller
|
|||
public function __construct(
|
||||
PageRepositoryInterface $pageRepository,
|
||||
SettingsService $settingsService,
|
||||
AuthService $authService,
|
||||
AssetService $assetService,
|
||||
SortingService $sortService,
|
||||
) {
|
||||
$this->pages = $pageRepository;
|
||||
$this->settings = $settingsService;
|
||||
$this->auth = $authService;
|
||||
$this->assets = $assetService;
|
||||
$this->sort = $sortService;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\Data\AuthService;
|
||||
use App\Interfaces\MemberRepositoryInterface;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RouteController extends Controller
|
||||
|
@ -11,20 +11,20 @@ class RouteController extends Controller
|
|||
protected $gate;
|
||||
protected $theme;
|
||||
protected $front;
|
||||
protected $auth;
|
||||
protected $member;
|
||||
|
||||
public function __construct(
|
||||
DashController $dashController,
|
||||
AuthController $authController,
|
||||
ThemeController $themeController,
|
||||
FrontController $frontController,
|
||||
AuthService $authService,
|
||||
MemberRepositoryInterface $memberRepo,
|
||||
) {
|
||||
$this->dash = $dashController;
|
||||
$this->gate = $authController;
|
||||
$this->theme = $themeController;
|
||||
$this->front = $frontController;
|
||||
$this->auth = $authService;
|
||||
$this->dash = $dashController;
|
||||
$this->gate = $authController;
|
||||
$this->theme = $themeController;
|
||||
$this->front = $frontController;
|
||||
$this->member = $memberRepo;
|
||||
}
|
||||
|
||||
public function get($first = null, $second = null, $third = null, $fourth = null)
|
||||
|
@ -32,14 +32,14 @@ class RouteController extends Controller
|
|||
if (isset($first) && !is_numeric($first)) {
|
||||
switch ($first) {
|
||||
case 'dashboard':
|
||||
if ($this->auth::status()) {
|
||||
if ($this->member::status()) {
|
||||
return $this->dash->init($second, $third, $fourth);
|
||||
} else {
|
||||
return $this->dash->login();
|
||||
}
|
||||
break;
|
||||
case 'theme':
|
||||
if ($this->auth::status()) {
|
||||
if ($this->member::status()) {
|
||||
if (isset($second)) {
|
||||
return $this->theme->getView($third);
|
||||
} else {
|
||||
|
|
|
@ -4,27 +4,27 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Interfaces\PageRepositoryInterface;
|
||||
use App\Services\Assets\AssetService;
|
||||
use App\Services\Data\AuthService;
|
||||
use App\Interfaces\MemberRepositoryInterface;
|
||||
use App\Services\Data\SortingService;
|
||||
use App\Services\Data\ThemeService;
|
||||
|
||||
class ThemeController extends Controller
|
||||
{
|
||||
protected PageRepositoryInterface $pages;
|
||||
protected AuthService $auth;
|
||||
protected MemberRepositoryInterface $member;
|
||||
protected AssetService $assets;
|
||||
protected SortingService $sort;
|
||||
protected ThemeService $themes;
|
||||
|
||||
public function __construct(
|
||||
PageRepositoryInterface $pageRepository,
|
||||
AuthService $authService,
|
||||
MemberRepositoryInterface $memberRepo,
|
||||
AssetService $assetService,
|
||||
SortingService $sortService,
|
||||
ThemeService $themeService,
|
||||
) {
|
||||
$this->pages = $pageRepository;
|
||||
$this->auth = $authService;
|
||||
$this->member = $memberRepo;
|
||||
$this->assets = $assetService;
|
||||
$this->sort = $sortService;
|
||||
$this->themes = $themeService;
|
||||
|
@ -32,9 +32,9 @@ class ThemeController extends Controller
|
|||
|
||||
public function start()
|
||||
{
|
||||
if ($this->auth::status()) {
|
||||
if ($this->member::status()) {
|
||||
return view('theme.start', [
|
||||
"status" => $this->auth::status(),
|
||||
"status" => $this->member::status(),
|
||||
"title" => "Fipamo Theme Kit",
|
||||
"pages" => $this->themes->getCustomViews('page')
|
||||
]);
|
||||
|
@ -73,7 +73,7 @@ class ThemeController extends Controller
|
|||
$page = $this->pages->getById('F4429D34-25E7-4CA9-9B0A-742810277505');
|
||||
$pageData = $this->sort->page($page);
|
||||
}
|
||||
if ($this->auth::status()) {
|
||||
if ($this->member::status()) {
|
||||
return view($template, $pageData);
|
||||
} else {
|
||||
return redirect('dashboard/start');
|
||||
|
|
22
app/Interfaces/MemberRepositoryInterface.php
Normal file
22
app/Interfaces/MemberRepositoryInterface.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
|
||||
interface MemberRepositoryInterface
|
||||
{
|
||||
public function getAll();
|
||||
|
||||
public function getByID($id);
|
||||
|
||||
public function getByHandle($handle);
|
||||
|
||||
public function delete($id);
|
||||
|
||||
public function create($member);
|
||||
|
||||
public function update($id);
|
||||
|
||||
public function auth($request);
|
||||
|
||||
public static function status();
|
||||
}
|
|
@ -6,6 +6,8 @@ use Illuminate\Support\ServiceProvider;
|
|||
//Repos
|
||||
use App\Repositories\PageRepository;
|
||||
use App\Interfaces\PageRepositoryInterface;
|
||||
use App\Repositories\MemberRepository;
|
||||
use App\Interfaces\MemberRepositoryInterface;
|
||||
//Asset Services
|
||||
use App\Services\Assets\AssetService;
|
||||
use App\Services\Assets\DocService;
|
||||
|
@ -13,7 +15,6 @@ use App\Services\Assets\FileUploadService;
|
|||
use App\Services\Assets\RenderService;
|
||||
//Data Services
|
||||
use App\Services\Data\SettingsService;
|
||||
use App\Services\Data\AuthService;
|
||||
use App\Services\Data\ContentService;
|
||||
use App\Services\Data\PaginateService;
|
||||
use App\Services\Data\ThemeService;
|
||||
|
@ -34,10 +35,6 @@ class FipamoServiceProvider extends ServiceProvider
|
|||
return new SettingsService(new DocService(), new ContentService());
|
||||
});
|
||||
|
||||
$this->app->bind(AuthService::class, function ($app) {
|
||||
return new AuthService(new SettingsService(new DocService(), new ContentService()));
|
||||
});
|
||||
|
||||
$this->app->bind(ContentService::class, function ($app) {
|
||||
return new ContentService();
|
||||
});
|
||||
|
@ -103,5 +100,6 @@ class FipamoServiceProvider extends ServiceProvider
|
|||
public function boot(): void
|
||||
{
|
||||
$this->app->bind(PageRepositoryInterface::class, PageRepository::class);
|
||||
$this->app->bind(MemberRepositoryInterface::class, MemberRepository::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\Data;
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Interfaces\MemberRepositoryInterface;
|
||||
use ReallySimpleJWT\Token;
|
||||
|
||||
use function _\find;
|
||||
|
||||
class AuthService
|
||||
class MemberRepository implements MemberRepositoryInterface
|
||||
{
|
||||
protected $config;
|
||||
protected $request;
|
||||
protected $folks;
|
||||
|
||||
public function __construct(SettingsService $config)
|
||||
public function __construct()
|
||||
{
|
||||
$this->config = $config;
|
||||
if (file_exists(env('FOLKS_PATH'))) {
|
||||
$this->folks = json_decode(file_get_contents(env('FOLKS_PATH')), true);
|
||||
} else {
|
||||
$this->folks = json_decode(file_get_contents('../content/init/folks-template.json'), true);
|
||||
}
|
||||
}
|
||||
|
||||
public function check($request)
|
||||
public function getAll()
|
||||
{
|
||||
$folks = $this->config->getFolks();
|
||||
$found = find($folks, ['handle' => $request->handle]);
|
||||
return $this->$folks;
|
||||
}
|
||||
|
||||
public function getById($id)
|
||||
{
|
||||
$member = find($this->folks, ['id' => $id]);
|
||||
return $member;
|
||||
}
|
||||
|
||||
public function getByHandle($handle)
|
||||
{
|
||||
$member = find($this->folks, ['handle' => $handle]);
|
||||
return $member;
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
//delete member stuff
|
||||
}
|
||||
|
||||
public function create($member)
|
||||
{
|
||||
//make new member
|
||||
}
|
||||
|
||||
public function update($id)
|
||||
{
|
||||
//update member data
|
||||
}
|
||||
|
||||
public function auth($request)
|
||||
{
|
||||
//suth stuff
|
||||
$folks = $this->folks;
|
||||
$found = $this->getByHandle($request->handle);
|
||||
if ($found) {
|
||||
if (password_verify($request->password, $found['password'])) {
|
||||
$member = [
|
|
@ -10,20 +10,12 @@ use function _\find;
|
|||
class SettingsService
|
||||
{
|
||||
protected $settings;
|
||||
protected $folks;
|
||||
protected $tags;
|
||||
protected $docs;
|
||||
protected $contents;
|
||||
|
||||
public function __construct(DocService $docService, ContentService $contentService)
|
||||
{
|
||||
//if config files aren't avaiable, load templates
|
||||
if (file_exists(env('FOLKS_PATH'))) {
|
||||
$this->folks = json_decode(file_get_contents(env('FOLKS_PATH')), true);
|
||||
} else {
|
||||
$this->folks = json_decode(file_get_contents('../content/init/folks-template.json'), true);
|
||||
}
|
||||
|
||||
if (file_exists(env('TAGS_PATH'))) {
|
||||
$this->tags = json_decode(file_get_contents(env('TAGS_PATH')), true);
|
||||
} else {
|
||||
|
@ -74,11 +66,6 @@ class SettingsService
|
|||
return $this->tags;
|
||||
}
|
||||
|
||||
public function getFolks()
|
||||
{
|
||||
return $this->folks;
|
||||
}
|
||||
|
||||
public function updatePageIndex()
|
||||
{
|
||||
$this->settings = $this->loadSettings();
|
||||
|
|
Loading…
Add table
Reference in a new issue