diff --git a/.env.example b/.env.example index 4aae000..1d88053 100644 --- a/.env.example +++ b/.env.example @@ -52,4 +52,4 @@ VITE_PUSHER_PORT="${PUSHER_PORT}" VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" -HTTP_SECURE=false +HTTPS_AWARE=false diff --git a/README.md b/README.md index be0f80e..882e404 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ -# Laravel Template - Flowbite +# Voucher App + +This online shop to purchase wifi voucher for WISP/Small ISP Based -This just a laravel template with breeze react, user role based access crud with setup flowbite admin template ## Support me Trakteer Saya ## Requirements -- PHP 8.1 or latest -- Node 16+ or latest +- PHP 8.1 or latest +- Node 16+ or latest ## How to run @@ -32,3 +33,9 @@ password : password ```bash npm run build ``` + +## Rsync + +```bash +rsync -arP -e 'ssh -p 224' --exclude=node_modules --exclude=.git --exclude=.env --exclude=storage --exclude=public/hot . arm@ajikamaludin.id:/home/arm/projects/voucher +``` diff --git a/app/Http/Controllers/Customer/AuthController.php b/app/Http/Controllers/Customer/AuthController.php index 2204fe3..eb24631 100644 --- a/app/Http/Controllers/Customer/AuthController.php +++ b/app/Http/Controllers/Customer/AuthController.php @@ -23,8 +23,8 @@ class AuthController extends Controller public function update(Request $request) { $request->validate([ - 'username' => 'string|required|alpha_dash', - 'password' => 'string|required', + 'username' => 'required|string|alpha_dash', + 'password' => 'required|string', ]); $isAuth = Auth::guard('customer')->attempt(['username' => $request->username, 'password' => $request->password]); @@ -51,7 +51,14 @@ class AuthController extends Controller public function callback_google() { - $user = Socialite::driver('google')->user(); + $config = new Config( + env('GOOGLE_CLIENT_ID'), + env('GOOGLE_CLIENT_SECRET'), + route('customer.login.callback_google') + ); + $user = Socialite::driver('google') + ->setConfig($config) + ->user(); $customer = Customer::where('google_id', $user->id)->first(); if ($customer == null) { DB::beginTransaction(); @@ -87,12 +94,12 @@ class AuthController extends Controller public function store(Request $request) { $request->validate([ - 'fullname' => 'string|required', - 'name' => 'string|required', - 'address' => 'string|required', - 'phone' => 'string|required|numeric', - 'username' => 'string|required|min:5|alpha_dash|unique:customers,username', - 'password' => 'string|required|min:8|confirmed', + 'fullname' => 'required|string', + 'name' => 'required|string', + 'address' => 'required|string', + 'phone' => 'required|string|numeric', + 'username' => 'required|string|min:5|alpha_dash|unique:customers,username', + 'password' => 'required|string|min:8|confirmed', ]); DB::beginTransaction(); diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 968e27d..68242dd 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -69,5 +69,6 @@ class Kernel extends HttpKernel 'inertia.admin' => \App\Http\Middleware\HandleInertiaRequests::class, 'inertia.customer' => \App\Http\Middleware\HandleInertiaCustomerRequests::class, 'guard_should_customer' => \App\Http\Middleware\GuardCustomer::class, + 'http_secure_aware' => \App\Http\Middleware\HttpSecureAware::class, ]; } diff --git a/app/Http/Middleware/HandleInertiaCustomerRequests.php b/app/Http/Middleware/HandleInertiaCustomerRequests.php index 9579dbd..6f46927 100644 --- a/app/Http/Middleware/HandleInertiaCustomerRequests.php +++ b/app/Http/Middleware/HandleInertiaCustomerRequests.php @@ -31,7 +31,7 @@ class HandleInertiaCustomerRequests extends Middleware { return array_merge(parent::share($request), [ 'auth' => [ - 'user' => auth('customer')->user()->load(['level']), + 'user' => auth('customer')->user()?->load(['level']), ], 'flash' => [ 'message' => fn () => $request->session()->get('message') ?? ['type' => null, 'message' => null], diff --git a/resources/js/Layouts/CustomerLayout.jsx b/resources/js/Layouts/CustomerLayout.jsx index 17bd3f0..dd8557a 100644 --- a/resources/js/Layouts/CustomerLayout.jsx +++ b/resources/js/Layouts/CustomerLayout.jsx @@ -26,49 +26,47 @@ export default function CustomerLayout({ children }) { } return ( -
-
-
{children}
-
+
+
+
{children}
+
+
+
handleOnClick('home.index')} + > + +
+
+ +
+
+ 1 +
+
+
+
+ +
+ {user !== null ? (
handleOnClick('home.index')} + className="py-2 px-5 hover:bg-blue-200" + onClick={() => handleOnClick('customer.profile.index')} > - +
-
- -
-
- 1 -
-
-
-
- + ) : ( +
handleOnClick('customer.login')} + > +
- {user !== null ? ( -
- handleOnClick('customer.profile.index') - } - > - -
- ) : ( -
handleOnClick('customer.login')} - > - -
- )} -
+ )}
) diff --git a/resources/js/Pages/Home/Auth/Login.jsx b/resources/js/Pages/Home/Auth/Login.jsx index 0ac5cac..c97d370 100644 --- a/resources/js/Pages/Home/Auth/Login.jsx +++ b/resources/js/Pages/Home/Auth/Login.jsx @@ -41,7 +41,7 @@ export default function Index({ app_name, flash }) { return ( -
+
Sign in
@@ -85,7 +85,7 @@ export default function Index({ app_name, flash }) {
diff --git a/resources/js/Pages/Home/Auth/Register.jsx b/resources/js/Pages/Home/Auth/Register.jsx index 223e848..e628998 100644 --- a/resources/js/Pages/Home/Auth/Register.jsx +++ b/resources/js/Pages/Home/Auth/Register.jsx @@ -47,8 +47,8 @@ export default function Index({ app_name, flash }) { return ( - -
+ +
Register
diff --git a/resources/js/Pages/Home/Profile/Form.jsx b/resources/js/Pages/Home/Profile/Form.jsx index 2eee0a9..f4b8b83 100644 --- a/resources/js/Pages/Home/Profile/Form.jsx +++ b/resources/js/Pages/Home/Profile/Form.jsx @@ -49,8 +49,8 @@ export default function Index({ auth: { user }, flash }) { console.log(user) return ( - -
+ +
Profile
diff --git a/resources/js/Pages/Home/Profile/Index.jsx b/resources/js/Pages/Home/Profile/Index.jsx index 594088d..bad880c 100644 --- a/resources/js/Pages/Home/Profile/Index.jsx +++ b/resources/js/Pages/Home/Profile/Index.jsx @@ -24,8 +24,8 @@ export default function Index({ auth: { user } }) { return ( - -
+ +
{/* user */}
diff --git a/resources/views/app.blade.php b/resources/views/app.blade.php index bb79d7e..9f07086 100644 --- a/resources/views/app.blade.php +++ b/resources/views/app.blade.php @@ -3,6 +3,8 @@ + + {{ config('app.name', 'Laravel') }} diff --git a/routes/admin.php b/routes/admin.php index d324a37..1c16b1b 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -7,7 +7,7 @@ use App\Http\Controllers\RoleController; use App\Http\Controllers\UserController; use Illuminate\Support\Facades\Route; -Route::middleware(['inertia.admin']) +Route::middleware(['http_secure_aware', 'inertia.admin']) ->prefix('admin') ->group(function () { Route::get('/', fn () => redirect()->route('admin.login')); diff --git a/routes/web.php b/routes/web.php index 75f29d9..345f87f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -17,7 +17,7 @@ use Illuminate\Support\Facades\Route; | */ -Route::middleware(['guard_should_customer', 'inertia.customer'])->group(function () { +Route::middleware(['http_secure_aware', 'guard_should_customer', 'inertia.customer'])->group(function () { Route::get('/', [HomeController::class, 'index'])->name('home.index'); Route::middleware('auth:customer')->group(function () {