From 95e4e53277443f1b1369713ba7f3808f192133e9 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 8 Jun 2017 22:34:41 +0800 Subject: [PATCH 01/27] added admin model, routes, migrations,database,seed,views, also fix fblogincontroller typo --- .../Auth/AdminForgotPasswordController.php | 43 +++++++ .../Controllers/Auth/AdminLoginController.php | 43 +++++++ .../Auth/AdminResetPasswordController.php | 116 ++++++++++++++++++ admin/Controllers/Auth/Controller.php | 13 ++ admin/Controllers/Controller.php | 13 ++ admin/Controllers/DashboardController.php | 28 +++++ admin/Models/Auth/Admin.php | 44 +++++++ .../AdminResetPasswordNotification.php | 63 ++++++++++ admin/Observers/AdminObserver.php | 36 ++++++ ...inController.php => FBLoginController.php} | 0 .../Controllers/ResetPasswordController.php | 2 +- app/Exceptions/Handler.php | 13 +- .../Middleware/RedirectIfAuthenticated.php | 18 ++- app/Models/Auth/User.php | 3 +- app/Observers/UserObserver.php | 2 - app/Providers/AppServiceProvider.php | 3 + app/Providers/RouteServiceProvider.php | 11 ++ composer.json | 3 +- config/app.php | 2 + config/auth.php | 13 ++ .../2014_10_12_000000_create_users_table.php | 1 + .../2017_06_08_070222_create_admins_table.php | 37 ++++++ database/seeds/AdminTableSeeder.php | 25 ++++ database/seeds/UsersTableSeeder.php | 12 +- resources/views/admin/auth/login.blade.php | 60 +++++++++ resources/views/admin/dashboard.blade.php | 15 +++ .../views/admin/passwords/email.blade.php | 41 +++++++ .../views/admin/passwords/reset.blade.php | 65 ++++++++++ resources/views/components/who.blade.php | 17 +++ resources/views/home.blade.php | 15 +++ resources/views/layouts/admin.blade.php | 88 +++++++++++++ resources/views/welcome.blade.php | 93 ++++++++++++++ routes/admin.php | 23 ++++ routes/web.php | 10 +- 34 files changed, 952 insertions(+), 19 deletions(-) create mode 100644 admin/Controllers/Auth/AdminForgotPasswordController.php create mode 100644 admin/Controllers/Auth/AdminLoginController.php create mode 100644 admin/Controllers/Auth/AdminResetPasswordController.php create mode 100644 admin/Controllers/Auth/Controller.php create mode 100644 admin/Controllers/Controller.php create mode 100644 admin/Controllers/DashboardController.php create mode 100644 admin/Models/Auth/Admin.php create mode 100644 admin/Notifications/AdminResetPasswordNotification.php create mode 100644 admin/Observers/AdminObserver.php rename api/V1/Auth/Controllers/{FBloginController.php => FBLoginController.php} (100%) create mode 100644 database/migrations/2017_06_08_070222_create_admins_table.php create mode 100644 database/seeds/AdminTableSeeder.php create mode 100644 resources/views/admin/auth/login.blade.php create mode 100644 resources/views/admin/dashboard.blade.php create mode 100644 resources/views/admin/passwords/email.blade.php create mode 100644 resources/views/admin/passwords/reset.blade.php create mode 100644 resources/views/components/who.blade.php create mode 100644 resources/views/home.blade.php create mode 100644 resources/views/layouts/admin.blade.php create mode 100644 resources/views/welcome.blade.php create mode 100644 routes/admin.php diff --git a/admin/Controllers/Auth/AdminForgotPasswordController.php b/admin/Controllers/Auth/AdminForgotPasswordController.php new file mode 100644 index 0000000..ba0c44d --- /dev/null +++ b/admin/Controllers/Auth/AdminForgotPasswordController.php @@ -0,0 +1,43 @@ +middleware('guest:admin'); + } + + protected function broker() + { + return Password::broker('admins'); + } + + public function showLinkRequestForm() + { + + return view('admin.passwords.email'); + } +} diff --git a/admin/Controllers/Auth/AdminLoginController.php b/admin/Controllers/Auth/AdminLoginController.php new file mode 100644 index 0000000..bdd8d2a --- /dev/null +++ b/admin/Controllers/Auth/AdminLoginController.php @@ -0,0 +1,43 @@ +middleware('guest:admin', ['except' => ['logout']]); + } + + public function showLoginForm() + { + return view('admin.auth.login'); + } + + public function login(Request $request) + { + // Validate the form data + $this->validate($request, [ + 'email' => 'required|email', + 'password' => 'required|min:6' + ]); + + // Attempt to log the user in + if (Auth::guard('admin')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) { + // if successful, then redirect to their intended location + return redirect()->intended(route('admin.dashboard')); + } + + // if unsuccessful, then redirect back to the login with the form data + return redirect()->back()->withInput($request->only('email', 'remember')); + } + + public function logout() + { + Auth::guard('admin')->logout(); + return redirect('/'); + } +} diff --git a/admin/Controllers/Auth/AdminResetPasswordController.php b/admin/Controllers/Auth/AdminResetPasswordController.php new file mode 100644 index 0000000..0dbede5 --- /dev/null +++ b/admin/Controllers/Auth/AdminResetPasswordController.php @@ -0,0 +1,116 @@ +middleware('guest:admin'); + } + + protected function guard() + { + return Auth::guard('admin'); + } + + protected function broker() + { + return Password::broker('admins'); + } + + public function showResetForm(Request $request, $token = null) + { + return view('admin.passwords.reset')->with( + ['token' => $token, 'email' => $request->email] + ); + } + + protected function rules() + { + return [ + 'token' => 'required', + 'email' => 'required|email', + 'password' => 'required|confirmed|min:6', + ]; + } + + protected function validationErrorMessages() + { + return []; + } + public function reset(Request $request) + { + $this->validate($request, $this->rules(), $this->validationErrorMessages()); + + // Here we will attempt to reset the user's password. If it is successful we + // will update the password on an actual user model and persist it to the + // database. Otherwise we will parse the error and return the response. + $response = $this->broker()->reset( + $this->credentials($request), function ($user, $password) { + $this->resetPassword($user, $password); + } + ); + + // If the password was successfully reset, we will redirect the user back to + // the application's home authenticated view. If there is an error we can + // redirect them back to where they came from with their error message. + return $response == Password::PASSWORD_RESET + ? $this->sendResetResponse($response) + : $this->sendResetFailedResponse($request, $response); + } + + protected function credentials(Request $request) + { + return $request->only( + 'email', 'password', 'password_confirmation', 'token' + ); + } + + protected function resetPassword($user, $password) + { + $user->forceFill([ + 'password' => bcrypt($password), + 'remember_token' => Str::random(60), + ])->save(); + + $this->guard()->login($user); + } + + protected function sendResetResponse($response) + { + return redirect('admin.'.config('app.domain').'/dashboard') + ->with('status', trans($response)); + } + + protected function sendResetFailedResponse(Request $request, $response) + { + return redirect()->back() + ->withInput($request->only('email')) + ->withErrors(['email' => trans($response)]); + } +} diff --git a/admin/Controllers/Auth/Controller.php b/admin/Controllers/Auth/Controller.php new file mode 100644 index 0000000..8ec4b8c --- /dev/null +++ b/admin/Controllers/Auth/Controller.php @@ -0,0 +1,13 @@ +middleware('auth:admin'); + } + + /** + * Show the application dashboard. + * + * @return \Illuminate\Http\Response + */ + public function index() + { + return view('admin.dashboard'); + } +} diff --git a/admin/Models/Auth/Admin.php b/admin/Models/Auth/Admin.php new file mode 100644 index 0000000..e09e199 --- /dev/null +++ b/admin/Models/Auth/Admin.php @@ -0,0 +1,44 @@ +notify(new AdminResetPasswordNotification($token)); + } +} diff --git a/admin/Notifications/AdminResetPasswordNotification.php b/admin/Notifications/AdminResetPasswordNotification.php new file mode 100644 index 0000000..7af1c98 --- /dev/null +++ b/admin/Notifications/AdminResetPasswordNotification.php @@ -0,0 +1,63 @@ +token = $token; + } + + /** + * Get the notification's delivery channels. + * + * @param mixed $notifiable + * @return array + */ + public function via($notifiable) + { + return ['mail']; + } + + /** + * Get the mail representation of the notification. + * + * @param mixed $notifiable + * @return \Illuminate\Notifications\Messages\MailMessage + */ + public function toMail($notifiable) + { + return (new MailMessage) + ->line('You are receiving this email because we received a password reset request for your account.') + ->action('Reset Password', route('admin.password.reset', $this->token)) + ->line('If you did not request a password reset, no further action is required.'); + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * @return array + */ + public function toArray($notifiable) + { + return [ + // + ]; + } +} diff --git a/admin/Observers/AdminObserver.php b/admin/Observers/AdminObserver.php new file mode 100644 index 0000000..35efc09 --- /dev/null +++ b/admin/Observers/AdminObserver.php @@ -0,0 +1,36 @@ +id) && !is_numeric($admin->id)){ + $admin->id = Admin::generateUniqueID(); + } + } + + /** + * Listen to the Admin deleting event. + * + * @param Admin $admin + * @return void + */ + public function deleting(Admin $admin) + { + // + } + +} \ No newline at end of file diff --git a/api/V1/Auth/Controllers/FBloginController.php b/api/V1/Auth/Controllers/FBLoginController.php similarity index 100% rename from api/V1/Auth/Controllers/FBloginController.php rename to api/V1/Auth/Controllers/FBLoginController.php diff --git a/api/V1/Auth/Controllers/ResetPasswordController.php b/api/V1/Auth/Controllers/ResetPasswordController.php index a65ca97..df6b029 100644 --- a/api/V1/Auth/Controllers/ResetPasswordController.php +++ b/api/V1/Auth/Controllers/ResetPasswordController.php @@ -11,7 +11,7 @@ class ResetPasswordController extends Controller { // Redirect to Dashboard if Authenticated - protected $redirectTo = '/dashboard'; + protected $redirectTo = '/'; public function __construct() { diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index a747e31..8978268 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -60,6 +60,17 @@ protected function unauthenticated($request, AuthenticationException $exception) return response()->json(['error' => 'Unauthenticated.'], 401); } - return redirect()->guest(route('login')); + $guard = array_get($exception->guards(), 0); + + switch ($guard) { + case 'admin': + $login = 'admin.login'; + break; + + default: + $login = 'login'; + break; + } + return redirect()->guest(route($login)); } } diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index e4cec9c..479c415 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -17,10 +17,20 @@ class RedirectIfAuthenticated */ public function handle($request, Closure $next, $guard = null) { - if (Auth::guard($guard)->check()) { - return redirect('/home'); - } + switch ($guard) { + case 'admin': + if (Auth::guard($guard)->check()) { + return redirect()->route('admin.dashboard'); + } + break; - return $next($request); + default: + if (Auth::guard($guard)->check()) { + return redirect('/home'); + } + break; + } + + return $next($request); } } diff --git a/app/Models/Auth/User.php b/app/Models/Auth/User.php index 4f78590..7a4df69 100644 --- a/app/Models/Auth/User.php +++ b/app/Models/Auth/User.php @@ -8,10 +8,11 @@ use Silber\Bouncer\Database\HasRolesAndAbilities; use Tymon\JWTAuth\Contracts\JWTSubject as AuthenticatableUserContract; use App\Notifications\PasswordResetNotification; +use Illuminate\Database\Eloquent\SoftDeletes; class User extends Authenticatable implements AuthenticatableUserContract { - use Notifiable, UserMutator, HasRolesAndAbilities; + use Notifiable, UserMutator, HasRolesAndAbilities, SoftDeletes; protected $table = 'users'; diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php index 78debf0..43ff3f5 100644 --- a/app/Observers/UserObserver.php +++ b/app/Observers/UserObserver.php @@ -21,8 +21,6 @@ public function creating(User $user) $user->id = User::generateUniqueID(); } $user->code = User::generateUniqueCode(); - - } /** diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index a811766..db80cb2 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -5,6 +5,8 @@ use Illuminate\Support\ServiceProvider; use App\Models\Auth\User; use App\Observers\UserObserver; +use Admin\Models\Auth\Admin; +use Admin\Observers\AdminObserver; class AppServiceProvider extends ServiceProvider { @@ -16,6 +18,7 @@ class AppServiceProvider extends ServiceProvider public function boot() { User::observe(UserObserver::class); + Admin::observe(AdminObserver::class); } /** diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 5ea48d3..2d19687 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -16,6 +16,8 @@ class RouteServiceProvider extends ServiceProvider */ protected $namespace = 'App\Http\Controllers'; + protected $admin_namespace = 'Admin\Controllers'; + /** * Define your route model bindings, pattern filters, etc. * @@ -39,6 +41,8 @@ public function map() $this->mapWebRoutes(); + $this->mapAdminRoutes(); + // } @@ -56,6 +60,13 @@ protected function mapWebRoutes() ->group(base_path('routes/web.php')); } + protected function mapAdminRoutes() + { + Route::middleware('web') + ->namespace($this->admin_namespace) + ->group(base_path('routes/admin.php')); + } + /** * Define the "api" routes for the application. * diff --git a/composer.json b/composer.json index 225fdf2..b275384 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,8 @@ ], "psr-4": { "App\\": "app/", - "Api\\": "api/" + "Api\\": "api/", + "Admin\\": "admin/" } }, "autoload-dev": { diff --git a/config/app.php b/config/app.php index 6515b2b..9b0043c 100644 --- a/config/app.php +++ b/config/app.php @@ -53,6 +53,8 @@ 'url' => env('APP_URL', 'http://localhost'), + 'domain' => env('APP_DOMAIN', 'laravel.dev'), + /* |-------------------------------------------------------------------------- | Application Timezone diff --git a/config/auth.php b/config/auth.php index 4b11132..8541cf8 100644 --- a/config/auth.php +++ b/config/auth.php @@ -45,6 +45,10 @@ 'driver' => 'jwt', 'provider' => 'users', ], + 'admin' => [ + 'driver' => 'session', + 'provider' => 'admins', + ], ], /* @@ -69,6 +73,10 @@ 'driver' => 'eloquent', 'model' => App\Models\Auth\User::class, ], + 'admins' => [ + 'driver' => 'eloquent', + 'model' => Admin\Models\Auth\Admin::class, + ], // 'users' => [ // 'driver' => 'database', @@ -97,6 +105,11 @@ 'table' => 'password_resets', 'expire' => 60, ], + 'admins' => [ + 'provider' => 'admins', + 'table' => 'password_resets', + 'expire' => 15, + ], ], ]; diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 6bd3b2a..fe8fd5b 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -31,6 +31,7 @@ public function up() $table->unsignedTinyInteger('resent')->default(0); // For Sending Password Reset Email $table->json('settings')->nullable(); $table->rememberToken(); + $table->softDeletes(); $table->timestamps(); }); } diff --git a/database/migrations/2017_06_08_070222_create_admins_table.php b/database/migrations/2017_06_08_070222_create_admins_table.php new file mode 100644 index 0000000..6eff292 --- /dev/null +++ b/database/migrations/2017_06_08_070222_create_admins_table.php @@ -0,0 +1,37 @@ +increments('id'); + $table->string('name'); + $table->string('email')->unique(); + $table->string('job_title'); + $table->string('password'); + $table->rememberToken(); + $table->softDeletes(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('admins'); + } +} diff --git a/database/seeds/AdminTableSeeder.php b/database/seeds/AdminTableSeeder.php new file mode 100644 index 0000000..fbbdc2c --- /dev/null +++ b/database/seeds/AdminTableSeeder.php @@ -0,0 +1,25 @@ + 'admin@example.com', + 'job_title' => 'CEO', + 'name' => 'admin', + 'password' => 'password' + ]); + + } +} diff --git a/database/seeds/UsersTableSeeder.php b/database/seeds/UsersTableSeeder.php index eb3abb2..17b7b91 100644 --- a/database/seeds/UsersTableSeeder.php +++ b/database/seeds/UsersTableSeeder.php @@ -15,19 +15,21 @@ public function run() { \Bouncer::seeder(function () { // List All the Abilities of Each Roles - \Bouncer::allow('admin')->to(['ban-user', 'add-user', 'delete-user', 'view-user', 'edit-user']); - \Bouncer::allow('user')->to('update-profile'); + \Bouncer::allow('tenant')->to(['manage_users']); + \Bouncer::allow('manager')->to('manage_projects','manage_comment','manage_files'); + \Bouncer::allow('worker')->to('update_task','edit_profile', 'comment','upload_files'); + \Bouncer::allow('client')->to('edit_profile', 'edit_profile', 'comment' ,'upload_files'); }); $user = User::create([ - 'email' => 'admin@laravel.dev', - 'username' => 'superadmin', + 'email' => 'user@example.com', + 'username' => 'user', 'first_name' => 'John', 'last_name' => 'Doe', 'password' => 'password' ]); - \Bouncer::assign('admin')->to($user); + \Bouncer::assign('tenant')->to($user); // Gives All Abilities \Bouncer::allow($user)->everything(); diff --git a/resources/views/admin/auth/login.blade.php b/resources/views/admin/auth/login.blade.php new file mode 100644 index 0000000..13b40a7 --- /dev/null +++ b/resources/views/admin/auth/login.blade.php @@ -0,0 +1,60 @@ +@extends('layouts.admin') @section('content') +
+
+
+
+
ADMIN Login
+
+
+ {{ csrf_field() }} + +
+ + +
+ @if ($errors->has('email')) + + {{ $errors->first('email') }} + @endif +
+
+ +
+ + +
+ @if ($errors->has('password')) + + {{ $errors->first('password') }} + @endif +
+
+ +
+
+
+ +
+
+
+ +
+
+ + + + Forgot Your Password? + +
+
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php new file mode 100644 index 0000000..cab850f --- /dev/null +++ b/resources/views/admin/dashboard.blade.php @@ -0,0 +1,15 @@ +@extends('layouts.admin') @section('content') +
+
+
+
+
ADMIN Dashboard
+ +
+ @component('components.who') @endcomponent +
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/admin/passwords/email.blade.php b/resources/views/admin/passwords/email.blade.php new file mode 100644 index 0000000..331a760 --- /dev/null +++ b/resources/views/admin/passwords/email.blade.php @@ -0,0 +1,41 @@ +@extends('layouts.admin') @section('content') +
+
+
+
+
ADMIN Reset Password
+
+ @if (session('status')) +
+ {{ session('status') }} +
+ @endif + +
+ {{ csrf_field() }} + +
+ + +
+ @if ($errors->has('email')) + + {{ $errors->first('email') }} + @endif +
+
+ +
+
+ +
+
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/admin/passwords/reset.blade.php b/resources/views/admin/passwords/reset.blade.php new file mode 100644 index 0000000..4ddcfe8 --- /dev/null +++ b/resources/views/admin/passwords/reset.blade.php @@ -0,0 +1,65 @@ +@extends('layouts.admin') @section('content') +
+
+
+
+
ADMIN Reset Password
+ +
+ @if (session('status')) +
+ {{ session('status') }} +
+ @endif + +
+ {{ csrf_field() }} + + + +
+ + +
+ @if ($errors->has('email')) + + {{ $errors->first('email') }} + @endif +
+
+ +
+ + +
+ @if ($errors->has('password')) + + {{ $errors->first('password') }} + @endif +
+
+ +
+ +
+ @if ($errors->has('password_confirmation')) + + {{ $errors->first('password_confirmation') }} + @endif +
+
+ +
+
+ +
+
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/components/who.blade.php b/resources/views/components/who.blade.php new file mode 100644 index 0000000..34d8987 --- /dev/null +++ b/resources/views/components/who.blade.php @@ -0,0 +1,17 @@ +@if (Auth::guard('web')->check()) +

+ You are Logged In as a USER +

+@else +

+ You are Logged Out as a USER +

+@endif @if (Auth::guard('admin')->check()) +

+ You are Logged In as a ADMIN +

+@else +

+ You are Logged Out as a ADMIN +

+@endif \ No newline at end of file diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php new file mode 100644 index 0000000..28487b4 --- /dev/null +++ b/resources/views/home.blade.php @@ -0,0 +1,15 @@ +@extends('layouts.admin') @section('content') +
+
+
+
+
USER Dashboard
+ +
+ @component('components.who') @endcomponent +
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/layouts/admin.blade.php b/resources/views/layouts/admin.blade.php new file mode 100644 index 0000000..0e776fe --- /dev/null +++ b/resources/views/layouts/admin.blade.php @@ -0,0 +1,88 @@ + + + + + + + + + + + + {{ config('app.name', 'Laravel') }} + + + + + + + + + +
+ + + @yield('content') +
+ + + + + + \ No newline at end of file diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php new file mode 100644 index 0000000..10fce09 --- /dev/null +++ b/resources/views/welcome.blade.php @@ -0,0 +1,93 @@ + + + + + + + + + Laravel + + + + + + + + + +
+ @if (Route::has('login')) + + @endif + +
+
+
+
+ @component('components.who') @endcomponent +
+
+
+
+
+ + + \ No newline at end of file diff --git a/routes/admin.php b/routes/admin.php new file mode 100644 index 0000000..93917ab --- /dev/null +++ b/routes/admin.php @@ -0,0 +1,23 @@ + 'admin.'.config('app.domain')], function () { + // Authentication Routes + Route::get('/login', 'Auth\AdminLoginController@showLoginForm')->name('admin.login'); + Route::post('/login', 'Auth\AdminLoginController@login')->name('admin.login.submit'); + Route::get('/logout', 'Auth\AdminLoginController@logout')->name('admin.logout'); + + // Password reset Routes + Route::post('/password/email', 'Auth\AdminForgotPasswordController@sendResetLinkEmail')->name('admin.password.email'); + Route::get('/password/reset', 'Auth\AdminForgotPasswordController@showLinkRequestForm')->name('admin.password.request'); + Route::post('/password/reset', 'Auth\AdminResetPasswordController@reset'); + Route::get('/password/reset/{token}', 'Auth\AdminResetPasswordController@showResetForm')->name('admin.password.reset'); + // Admin Dashboard Route + Route::get('/', 'DashboardController@index')->name('admin.dashboard'); + +}); + +// Vue Router Catcher +// Cause Unpleasant Bug, if Place on web.php so we move it here +Route::get('/{vue?}', function () { + return view('app'); +})->where('vue', '[\/\w\.-]*')->name('app'); diff --git a/routes/web.php b/routes/web.php index 5d0ac27..af43d42 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,8 @@ where('vue', '[\/\w\.-]*')->name('app'); +// Add Your Web Routes Here +Route::group(['domain' => '{username}.'.config('app.domain')], function () { + Route::get('/', function ($username) { + return 'this is dashboard of ' .$username; + }); +}); \ No newline at end of file From a9df148e643bc463673b0f70f3621384aaefac68 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 8 Jun 2017 23:12:23 +0800 Subject: [PATCH 02/27] fix sp_id Cannot add foreign key constraint --- database/migrations/2014_10_12_000000_create_users_table.php | 1 - 1 file changed, 1 deletion(-) diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index fe8fd5b..bea8970 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -16,7 +16,6 @@ public function up() Schema::create('users', function (Blueprint $table) { $table->unsignedBigInteger('id'); // Allows Us to use Facebook ID $table->unsignedBigInteger('sp_id')->nullable(); // Sponsor ID - $table->foreign('sp_id')->references('id')->on('users'); $table->string('code',24); $table->string('first_name',32); $table->string('last_name',32); From 2184929ea902e58bbae5d890773076b895587d00 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 8 Jun 2017 23:14:32 +0800 Subject: [PATCH 03/27] added AdminTableseeder --- database/seeds/DatabaseSeeder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 2399bf1..cfb1fa5 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -12,5 +12,6 @@ class DatabaseSeeder extends Seeder public function run() { $this->call(UsersTableSeeder::class); + $this->call(AdminTableSeeder::class); } } From d114966fda8af9afcee24d91cb1a90d5bccf8651 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 8 Jun 2017 23:28:00 +0800 Subject: [PATCH 04/27] change to big interger entity id field --- database/migrations/2017_03_18_021252_create_bouncer_tables.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/2017_03_18_021252_create_bouncer_tables.php b/database/migrations/2017_03_18_021252_create_bouncer_tables.php index 714c845..6329264 100644 --- a/database/migrations/2017_03_18_021252_create_bouncer_tables.php +++ b/database/migrations/2017_03_18_021252_create_bouncer_tables.php @@ -18,7 +18,7 @@ public function up() $table->increments('id'); $table->string('name', 150); $table->string('title')->nullable(); - $table->integer('entity_id')->unsigned()->nullable(); + $table->unsignedBigInteger('entity_id')->unsigned()->nullable(); $table->string('entity_type', 150)->nullable(); $table->boolean('only_owned')->default(false); $table->timestamps(); From d6bfc8d911980e14008248ba731f32e95d9b50e9 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 8 Jun 2017 23:35:17 +0800 Subject: [PATCH 05/27] change ->morph --- .../migrations/2017_03_18_021252_create_bouncer_tables.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/database/migrations/2017_03_18_021252_create_bouncer_tables.php b/database/migrations/2017_03_18_021252_create_bouncer_tables.php index 6329264..3bdd20c 100644 --- a/database/migrations/2017_03_18_021252_create_bouncer_tables.php +++ b/database/migrations/2017_03_18_021252_create_bouncer_tables.php @@ -39,7 +39,8 @@ public function up() Schema::create(Models::table('assigned_roles'), function (Blueprint $table) { $table->integer('role_id')->unsigned()->index(); - $table->morphs('entity'); + $table->unsignedBigInteger('entity_id')->unsigned()->nullable(); + $table->string('entity_type', 150)->nullable(); $table->foreign('role_id')->references('id')->on(Models::table('roles')) ->onUpdate('cascade')->onDelete('cascade'); @@ -47,7 +48,8 @@ public function up() Schema::create(Models::table('permissions'), function (Blueprint $table) { $table->integer('ability_id')->unsigned()->index(); - $table->morphs('entity'); + $table->unsignedBigInteger('entity_id')->unsigned()->nullable(); + $table->string('entity_type', 150)->nullable(); $table->boolean('forbidden')->default(false); $table->foreign('ability_id')->references('id')->on(Models::table('abilities')) From acff1448266b7ad67b28a9fe94796a3e85f1a6b2 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 8 Jun 2017 23:36:52 +0800 Subject: [PATCH 06/27] change id to biginteger --- database/migrations/2017_06_08_070222_create_admins_table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/2017_06_08_070222_create_admins_table.php b/database/migrations/2017_06_08_070222_create_admins_table.php index 6eff292..cf9e9fb 100644 --- a/database/migrations/2017_06_08_070222_create_admins_table.php +++ b/database/migrations/2017_06_08_070222_create_admins_table.php @@ -14,7 +14,7 @@ class CreateAdminsTable extends Migration public function up() { Schema::create('admins', function (Blueprint $table) { - $table->increments('id'); + $table->unsignedBigInteger('id'); $table->string('name'); $table->string('email')->unique(); $table->string('job_title'); From 162d697c00b2f8d3193630f597b311aa8f0403da Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 00:13:57 +0800 Subject: [PATCH 07/27] remove username from web route --- routes/admin.php | 5 +++++ routes/web.php | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/routes/admin.php b/routes/admin.php index 93917ab..7dec08d 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -16,6 +16,11 @@ }); +Route::group(['domain' => '{username}.'.config('app.domain')], function () { + Route::get('/', function ($username) { + return 'this is dashboard of ' .$username; + }); +}); // Vue Router Catcher // Cause Unpleasant Bug, if Place on web.php so we move it here Route::get('/{vue?}', function () { diff --git a/routes/web.php b/routes/web.php index af43d42..d7a1e4f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,8 +1,3 @@ '{username}.'.config('app.domain')], function () { - Route::get('/', function ($username) { - return 'this is dashboard of ' .$username; - }); -}); \ No newline at end of file From db51c725719363b1de9ac869acab8f2091be5b27 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 00:22:49 +0800 Subject: [PATCH 08/27] change back to web vue router catcher --- routes/admin.php | 7 ++----- routes/web.php | 3 +++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/routes/admin.php b/routes/admin.php index 7dec08d..21e1fc1 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -21,8 +21,5 @@ return 'this is dashboard of ' .$username; }); }); -// Vue Router Catcher -// Cause Unpleasant Bug, if Place on web.php so we move it here -Route::get('/{vue?}', function () { - return view('app'); -})->where('vue', '[\/\w\.-]*')->name('app'); + + diff --git a/routes/web.php b/routes/web.php index d7a1e4f..220860c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,3 +1,6 @@ where('vue', '[\/\w\.-]*')->name('app'); \ No newline at end of file From 9be5128d336f48cf71a9bce2c6ff60921e55c7cd Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 00:25:06 +0800 Subject: [PATCH 09/27] vue-router catcher at www --- routes/web.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/routes/web.php b/routes/web.php index 220860c..c6abcc9 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,9 @@ 'www.'.config('app.domain')], function () { + Route::get('/{vue?}', function () { return view('app'); -})->where('vue', '[\/\w\.-]*')->name('app'); \ No newline at end of file + })->where('vue', '[\/\w\.-]*')->name('app'); +}); From ac277bec693ac614dfe00c689e66b48ff0de153d Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 00:27:02 +0800 Subject: [PATCH 10/27] move the user subdomain to web --- routes/admin.php | 6 +----- routes/web.php | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/routes/admin.php b/routes/admin.php index 21e1fc1..e602c2f 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -16,10 +16,6 @@ }); -Route::group(['domain' => '{username}.'.config('app.domain')], function () { - Route::get('/', function ($username) { - return 'this is dashboard of ' .$username; - }); -}); + diff --git a/routes/web.php b/routes/web.php index c6abcc9..cd1a3ee 100644 --- a/routes/web.php +++ b/routes/web.php @@ -7,3 +7,9 @@ return view('app'); })->where('vue', '[\/\w\.-]*')->name('app'); }); + +Route::group(['domain' => '{username}.'.config('app.domain')], function () { + Route::get('/', function ($username) { + return 'this is dashboard of ' .$username; + }); +}); From 941bd3ce7cffda2b78ce4dc89795b5e000716eeb Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 00:36:01 +0800 Subject: [PATCH 11/27] redirect non www to www --- routes/web.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/routes/web.php b/routes/web.php index cd1a3ee..a412906 100644 --- a/routes/web.php +++ b/routes/web.php @@ -13,3 +13,9 @@ return 'this is dashboard of ' .$username; }); }); + +Route::group(['domain' => config('app.domain')], function () { + Route::get('/', function ($username) { + return redirect('www.'.config('app.domain')); + }); +}); \ No newline at end of file From 5f4fd08fa8c6433069859eb2ed440aa3b666982f Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 00:38:39 +0800 Subject: [PATCH 12/27] remove variable in the route redirect --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index a412906..2107716 100644 --- a/routes/web.php +++ b/routes/web.php @@ -15,7 +15,7 @@ }); Route::group(['domain' => config('app.domain')], function () { - Route::get('/', function ($username) { + Route::get('/', function () { return redirect('www.'.config('app.domain')); }); }); \ No newline at end of file From d4e679f0ad97c7fc1d48944df80e6feb131e07f5 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 00:40:54 +0800 Subject: [PATCH 13/27] redirec to name route app --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 2107716..af96188 100644 --- a/routes/web.php +++ b/routes/web.php @@ -16,6 +16,6 @@ Route::group(['domain' => config('app.domain')], function () { Route::get('/', function () { - return redirect('www.'.config('app.domain')); + return redirect()->route('app'); }); }); \ No newline at end of file From d17c30ad702a7ebf7232e3f40ceaedfdec6b9a5f Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 00:47:57 +0800 Subject: [PATCH 14/27] create 2 method for domaincontroller --- app/Http/Controllers/DomainController.php | 17 +++++++++++++++++ routes/web.php | 8 ++------ 2 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 app/Http/Controllers/DomainController.php diff --git a/app/Http/Controllers/DomainController.php b/app/Http/Controllers/DomainController.php new file mode 100644 index 0000000..d63b11b --- /dev/null +++ b/app/Http/Controllers/DomainController.php @@ -0,0 +1,17 @@ +route('app'); + } + + public function vueRouterCatcher() + { + return view('app'); + } +} \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index af96188..6a12da5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,9 +3,7 @@ // Add Your Web Routes Here Route::group(['domain' => 'www.'.config('app.domain')], function () { - Route::get('/{vue?}', function () { - return view('app'); - })->where('vue', '[\/\w\.-]*')->name('app'); + Route::get('/{vue?}', 'DomainController@vueRouterCatcher')->where('vue', '[\/\w\.-]*')->name('app'); }); Route::group(['domain' => '{username}.'.config('app.domain')], function () { @@ -15,7 +13,5 @@ }); Route::group(['domain' => config('app.domain')], function () { - Route::get('/', function () { - return redirect()->route('app'); - }); + Route::get('/', 'DomainController@redirectNonWWWToWWW'); }); \ No newline at end of file From 01f1bf88b49f9b2ab79cee89792d88f4841d994c Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 00:50:32 +0800 Subject: [PATCH 15/27] all slugs of non www will be redirected to www --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 6a12da5..a836b07 100644 --- a/routes/web.php +++ b/routes/web.php @@ -13,5 +13,5 @@ }); Route::group(['domain' => config('app.domain')], function () { - Route::get('/', 'DomainController@redirectNonWWWToWWW'); + Route::get('/{slug?}', 'DomainController@redirectNonWWWToWWW')->where('vue', '[\/\w\.-]*')->name('redirectToWWW'); }); \ No newline at end of file From fdb7b97b217d61efdbd57e2779c68f14f8d8ae8c Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 00:54:42 +0800 Subject: [PATCH 16/27] added a regex to filter admin, api, support in wildcard subdomain routes --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index a836b07..c7811a8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -10,7 +10,7 @@ Route::get('/', function ($username) { return 'this is dashboard of ' .$username; }); -}); +})->where('username','^/\b([a-z0-9]+)\b(? config('app.domain')], function () { Route::get('/{slug?}', 'DomainController@redirectNonWWWToWWW')->where('vue', '[\/\w\.-]*')->name('redirectToWWW'); From 20f6251a2f2c1e5b59ff9ef87f3ef60dd629ae71 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 01:06:33 +0800 Subject: [PATCH 17/27] test regex if working --- routes/web.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/web.php b/routes/web.php index c7811a8..c8672db 100644 --- a/routes/web.php +++ b/routes/web.php @@ -10,8 +10,8 @@ Route::get('/', function ($username) { return 'this is dashboard of ' .$username; }); -})->where('username','^/\b([a-z0-9]+)\b(?where('username','/(?!admin|api|support)([\w-]+)/'); Route::group(['domain' => config('app.domain')], function () { - Route::get('/{slug?}', 'DomainController@redirectNonWWWToWWW')->where('vue', '[\/\w\.-]*')->name('redirectToWWW'); + Route::get('/{slug?}', 'DomainController@redirectNonWWWToWWW')->where('slug', '[\/\w\.-]*')->name('redirectToWWW'); }); \ No newline at end of file From c40c3c485070f2e16aee8e74c98a46b0bf0023e8 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 01:09:10 +0800 Subject: [PATCH 18/27] test another regex --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index c8672db..184452d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -10,7 +10,7 @@ Route::get('/', function ($username) { return 'this is dashboard of ' .$username; }); -})->where('username','/(?!admin|api|support)([\w-]+)/'); +})->where('username', '^(?!admin|support|api)\w*'); Route::group(['domain' => config('app.domain')], function () { Route::get('/{slug?}', 'DomainController@redirectNonWWWToWWW')->where('slug', '[\/\w\.-]*')->name('redirectToWWW'); From 259d85e71acd0c921ed6ea25c1955583643b889b Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 01:16:50 +0800 Subject: [PATCH 19/27] test where params --- routes/web.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/web.php b/routes/web.php index 184452d..d8fde2c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6,11 +6,11 @@ Route::get('/{vue?}', 'DomainController@vueRouterCatcher')->where('vue', '[\/\w\.-]*')->name('app'); }); -Route::group(['domain' => '{username}.'.config('app.domain')], function () { +Route::group(['domain' => '{username}.'.config('app.domain'), 'where' => ['username' => '^(?!(?:static|my|admin|www)$).*$']], function () { Route::get('/', function ($username) { return 'this is dashboard of ' .$username; }); -})->where('username', '^(?!admin|support|api)\w*'); +}); Route::group(['domain' => config('app.domain')], function () { Route::get('/{slug?}', 'DomainController@redirectNonWWWToWWW')->where('slug', '[\/\w\.-]*')->name('redirectToWWW'); From f58b329ae988715fee8b7a953ceec3e98a24e6f9 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 01:24:19 +0800 Subject: [PATCH 20/27] added route pattern globally --- app/Providers/RouteServiceProvider.php | 5 +++-- routes/web.php | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 2d19687..47cb8aa 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -25,8 +25,9 @@ class RouteServiceProvider extends ServiceProvider */ public function boot() { - // - + Route::pattern('vue', '[\/\w\.-]*'); + Route::pattern('nonwww', '[\/\w\.-]*'); + Route::pattern('username', '^(?!(?:static|my|support|api|superadmin|test|admin|www)$).*$'); parent::boot(); } diff --git a/routes/web.php b/routes/web.php index d8fde2c..a1ea2b6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,15 +3,15 @@ // Add Your Web Routes Here Route::group(['domain' => 'www.'.config('app.domain')], function () { - Route::get('/{vue?}', 'DomainController@vueRouterCatcher')->where('vue', '[\/\w\.-]*')->name('app'); + Route::get('/{vue?}', 'DomainController@vueRouterCatcher')->name('app'); }); -Route::group(['domain' => '{username}.'.config('app.domain'), 'where' => ['username' => '^(?!(?:static|my|admin|www)$).*$']], function () { +Route::group(['domain' => '{username}.'.config('app.domain')], function () { Route::get('/', function ($username) { return 'this is dashboard of ' .$username; }); }); Route::group(['domain' => config('app.domain')], function () { - Route::get('/{slug?}', 'DomainController@redirectNonWWWToWWW')->where('slug', '[\/\w\.-]*')->name('redirectToWWW'); + Route::get('/{nonwww?}', 'DomainController@redirectNonWWWToWWW')->name('redirectToWWW'); }); \ No newline at end of file From 517f5b65cbeff2f9c104e5372f5b66022e7d0ee6 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 01:29:18 +0800 Subject: [PATCH 21/27] admin subdomain excluded' --- app/Providers/RouteServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 47cb8aa..134db60 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -27,7 +27,7 @@ public function boot() { Route::pattern('vue', '[\/\w\.-]*'); Route::pattern('nonwww', '[\/\w\.-]*'); - Route::pattern('username', '^(?!(?:static|my|support|api|superadmin|test|admin|www)$).*$'); + Route::pattern('username', '^((?!admin).)*$'); parent::boot(); } From b8daff1e8ea1a5ac88a28d25a7730658991f6c31 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 01:31:42 +0800 Subject: [PATCH 22/27] username except admin --- app/Providers/RouteServiceProvider.php | 2 +- routes/web.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 134db60..7c2ef96 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -27,7 +27,7 @@ public function boot() { Route::pattern('vue', '[\/\w\.-]*'); Route::pattern('nonwww', '[\/\w\.-]*'); - Route::pattern('username', '^((?!admin).)*$'); + Route::pattern('username', '(?!admin).*'); parent::boot(); } diff --git a/routes/web.php b/routes/web.php index a1ea2b6..9ce6831 100644 --- a/routes/web.php +++ b/routes/web.php @@ -8,7 +8,7 @@ Route::group(['domain' => '{username}.'.config('app.domain')], function () { Route::get('/', function ($username) { - return 'this is dashboard of ' .$username; + return 'this is dashboard of ' .$username; }); }); From 1f149bc41984b85c031995ece3682c93eb12d941 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 01:38:04 +0800 Subject: [PATCH 23/27] test new regex --- app/Providers/RouteServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 7c2ef96..69049d3 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -27,7 +27,7 @@ public function boot() { Route::pattern('vue', '[\/\w\.-]*'); Route::pattern('nonwww', '[\/\w\.-]*'); - Route::pattern('username', '(?!admin).*'); + Route::pattern('username', '\b(admin|support|api|static)\b'); parent::boot(); } From cc4fa21b2f5dc29a401c42a0ad623d1080895743 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 01:50:03 +0800 Subject: [PATCH 24/27] router patter exclude list of words --- app/Providers/RouteServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 69049d3..a36d54a 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -27,7 +27,7 @@ public function boot() { Route::pattern('vue', '[\/\w\.-]*'); Route::pattern('nonwww', '[\/\w\.-]*'); - Route::pattern('username', '\b(admin|support|api|static)\b'); + Route::pattern('username', '^(?!.*(admin|support|api|static|superadmin|helpdesk)).*$'); parent::boot(); } From a30cf02f9d9e03244f2b6fd57e617d375a93d9d0 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 02:01:27 +0800 Subject: [PATCH 25/27] added bunch of stuff to be reserve subdomain name --- app/Providers/RouteServiceProvider.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index a36d54a..9275528 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -27,7 +27,9 @@ public function boot() { Route::pattern('vue', '[\/\w\.-]*'); Route::pattern('nonwww', '[\/\w\.-]*'); - Route::pattern('username', '^(?!.*(admin|support|api|static|superadmin|helpdesk)).*$'); + Route::pattern('username', '^(?!.*( + admin|support|api|static|superadmin|helpdesk|team|staging|webmail|username|stats|status|payment|mobile|administrator|admins|account|accounts|administrators|anonymous|assets|billing|billings|contact|e-mail|mail|example|forum|feedback|hostmaster|official|portal|login|register|logout|teams|data|main|sitemap|staff|staffs|webmaster|search|shop|e-commerce|www|cpanel|dashboard|backend|web|money|bank|currency + )).*$'); parent::boot(); } From b38b5b0f232a14ce7ea4ffb64c88fcb6e16a0911 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 02:04:04 +0800 Subject: [PATCH 26/27] change username to subdomain key in routes pattern --- app/Providers/RouteServiceProvider.php | 2 +- routes/web.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 9275528..1ee38e5 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -27,7 +27,7 @@ public function boot() { Route::pattern('vue', '[\/\w\.-]*'); Route::pattern('nonwww', '[\/\w\.-]*'); - Route::pattern('username', '^(?!.*( + Route::pattern('subdomain', '^(?!.*( admin|support|api|static|superadmin|helpdesk|team|staging|webmail|username|stats|status|payment|mobile|administrator|admins|account|accounts|administrators|anonymous|assets|billing|billings|contact|e-mail|mail|example|forum|feedback|hostmaster|official|portal|login|register|logout|teams|data|main|sitemap|staff|staffs|webmaster|search|shop|e-commerce|www|cpanel|dashboard|backend|web|money|bank|currency )).*$'); parent::boot(); diff --git a/routes/web.php b/routes/web.php index 9ce6831..c86df2d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6,9 +6,9 @@ Route::get('/{vue?}', 'DomainController@vueRouterCatcher')->name('app'); }); -Route::group(['domain' => '{username}.'.config('app.domain')], function () { - Route::get('/', function ($username) { - return 'this is dashboard of ' .$username; +Route::group(['domain' => '{subdomain}.'.config('app.domain')], function () { + Route::get('/', function ($subdomain) { + return 'this is dashboard of ' .$subdomain; }); }); From b91d2c26a80a161af83632f9501d7f3192367e42 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 9 Jun 2017 02:08:19 +0800 Subject: [PATCH 27/27] exclude only api admin and www --- app/Providers/RouteServiceProvider.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 1ee38e5..d0e2c80 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -27,9 +27,7 @@ public function boot() { Route::pattern('vue', '[\/\w\.-]*'); Route::pattern('nonwww', '[\/\w\.-]*'); - Route::pattern('subdomain', '^(?!.*( - admin|support|api|static|superadmin|helpdesk|team|staging|webmail|username|stats|status|payment|mobile|administrator|admins|account|accounts|administrators|anonymous|assets|billing|billings|contact|e-mail|mail|example|forum|feedback|hostmaster|official|portal|login|register|logout|teams|data|main|sitemap|staff|staffs|webmaster|search|shop|e-commerce|www|cpanel|dashboard|backend|web|money|bank|currency - )).*$'); + Route::pattern('subdomain', '^(?!.*(admin|api|www)).*$'); parent::boot(); }