├── public ├── favicon.ico ├── robots.txt ├── img │ └── logos │ │ ├── teamsy.png │ │ ├── teamsy_on_dark.png │ │ ├── workflow-mark-on-white.svg │ │ └── workflow-logo-on-dark.svg ├── mix-manifest.json ├── .htaccess └── index.php ├── bootstrap ├── cache │ └── .gitignore └── app.php ├── resources ├── js │ ├── app.js │ └── bootstrap.js ├── views │ ├── livewire │ │ ├── department-form.blade.php │ │ └── auth │ │ │ ├── verify.blade.php │ │ │ ├── passwords │ │ │ ├── confirm.blade.php │ │ │ ├── email.blade.php │ │ │ └── reset.blade.php │ │ │ ├── register.blade.php │ │ │ └── login.blade.php │ ├── auth │ │ ├── login.blade.php │ │ ├── register.blade.php │ │ ├── verify.blade.php │ │ └── passwords │ │ │ ├── email.blade.php │ │ │ ├── confirm.blade.php │ │ │ └── reset.blade.php │ ├── components │ │ ├── loading.blade.php │ │ ├── document-icon.blade.php │ │ ├── desktop-nav-link.blade.php │ │ ├── th.blade.php │ │ ├── logo.blade.php │ │ ├── text-input.blade.php │ │ └── login-chart.blade.php │ ├── layouts │ │ ├── auth.blade.php │ │ └── base.blade.php │ ├── team.blade.php │ ├── dashboard.blade.php │ ├── users │ │ └── create.blade.php │ ├── vendor │ │ └── pagination │ │ │ └── simple-default.blade.php │ └── welcome.blade.php └── lang │ └── en │ ├── pagination.php │ ├── auth.php │ └── passwords.php ├── storage ├── logs │ └── .gitignore ├── app │ ├── public │ │ └── .gitignore │ └── .gitignore ├── debugbar │ └── .gitignore └── framework │ ├── testing │ └── .gitignore │ ├── views │ └── .gitignore │ ├── cache │ ├── data │ │ └── .gitignore │ └── .gitignore │ ├── sessions │ └── .gitignore │ └── .gitignore ├── database ├── .gitignore ├── seeds │ ├── DatabaseSeeder.php │ └── DemoSeeder.php ├── factories │ ├── PhoneFactory.php │ ├── TenantFactory.php │ ├── LoginFactory.php │ └── UserFactory.php └── migrations │ ├── 2020_06_03_032546_create_tenants_table.php │ ├── 2020_06_12_024233_create_phones_table.php │ ├── 2020_06_12_021646_create_departments_table.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2020_08_02_155726_create_logins_table.php │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ ├── 2020_07_30_045803_create_documents_table.php │ └── 2014_10_12_000000_create_users_table.php ├── .idea ├── .gitignore ├── codeStyles │ └── codeStyleConfig.xml ├── misc.xml ├── vcs.xml ├── laravel-plugin.xml ├── phpunit.xml ├── modules.xml └── php-test-framework.xml ├── .gitattributes ├── stubs ├── model.pivot.stub ├── controller.plain.stub ├── model.stub ├── seeder.stub ├── factory.stub ├── test.unit.stub ├── policy.plain.stub ├── middleware.stub ├── controller.invokable.stub ├── test.stub ├── migration.stub ├── job.stub ├── request.stub ├── migration.update.stub ├── job.queued.stub ├── migration.create.stub ├── rule.stub ├── console.stub ├── controller.api.stub ├── controller.model.api.stub ├── controller.stub ├── controller.model.stub ├── controller.nested.api.stub ├── policy.stub └── controller.nested.stub ├── .gitignore ├── .styleci.yml ├── app ├── Tenant.php ├── Phone.php ├── Login.php ├── Department.php ├── Http │ ├── Controllers │ │ ├── Auth │ │ │ ├── PasswordResetController.php │ │ │ ├── LogoutController.php │ │ │ └── EmailVerificationController.php │ │ ├── Controller.php │ │ ├── ImpersonationController.php │ │ ├── DocumentController.php │ │ └── HomeController.php │ ├── Middleware │ │ ├── EncryptCookies.php │ │ ├── VerifyCsrfToken.php │ │ ├── CheckForMaintenanceMode.php │ │ ├── TrimStrings.php │ │ ├── TrustHosts.php │ │ ├── TrustProxies.php │ │ ├── Authenticate.php │ │ └── RedirectIfAuthenticated.php │ ├── Livewire │ │ ├── Auth │ │ │ ├── Passwords │ │ │ │ ├── Confirm.php │ │ │ │ ├── Email.php │ │ │ │ └── Reset.php │ │ │ ├── Verify.php │ │ │ ├── Login.php │ │ │ └── Register.php │ │ ├── DepartmentForm.php │ │ ├── ShowUsers.php │ │ └── AddUser.php │ └── Kernel.php ├── Providers │ ├── BroadcastServiceProvider.php │ ├── AuthServiceProvider.php │ ├── AppServiceProvider.php │ ├── EventServiceProvider.php │ └── RouteServiceProvider.php ├── Document.php ├── Traits │ └── BelongsToTenant.php ├── Listeners │ ├── ClearTenantIdFromSession.php │ ├── SetTenantIdInSession.php │ └── RecordLogin.php ├── Scopes │ └── TenantScope.php ├── Console │ └── Kernel.php ├── Charts │ └── LoginChart.php ├── Exceptions │ └── Handler.php └── User.php ├── .editorconfig ├── tests ├── Unit │ └── ExampleTest.php ├── Feature │ ├── ExampleTest.php │ ├── Auth │ │ ├── LogoutTest.php │ │ ├── Passwords │ │ │ ├── EmailTest.php │ │ │ ├── ConfirmTest.php │ │ │ └── ResetTest.php │ │ ├── VerifyTest.php │ │ ├── LoginTest.php │ │ └── RegisterTest.php │ └── TenantScopeTest.php ├── CreatesApplication.php └── TestCase.php ├── routes ├── channels.php ├── api.php ├── console.php └── web.php ├── server.php ├── webpack.mix.js ├── config ├── cors.php ├── services.php ├── view.php ├── hashing.php ├── broadcasting.php ├── queue.php ├── filesystems.php ├── logging.php ├── cache.php ├── mail.php ├── livewire.php └── auth.php ├── .env.example ├── tailwind.config.js ├── package.json ├── phpunit.xml ├── README.md ├── artisan └── composer.json /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /resources/js/app.js: -------------------------------------------------------------------------------- 1 | require('./bootstrap'); 2 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | *.sqlite-journal 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/debugbar/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /public/img/logos/teamsy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iAmKevinMcKee/teamsy/HEAD/public/img/logos/teamsy.png -------------------------------------------------------------------------------- /public/mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/js/app.js": "/js/app.js", 3 | "/css/app.css": "/css/app.css" 4 | } 5 | -------------------------------------------------------------------------------- /public/img/logos/teamsy_on_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iAmKevinMcKee/teamsy/HEAD/public/img/logos/teamsy_on_dark.png -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | schedule-* 4 | compiled.php 5 | services.json 6 | events.scanned.php 7 | routes.scanned.php 8 | down 9 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /stubs/model.pivot.stub: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /resources/views/livewire/department-form.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | @if($success)
Saved
@endif 5 |
6 | -------------------------------------------------------------------------------- /.idea/laravel-plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /resources/views/auth/login.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.auth') 2 | @section('title', 'Sign in to your account') 3 | 4 | @section('content') 5 |
6 | @livewire('auth.login') 7 |
8 | @endsection 9 | -------------------------------------------------------------------------------- /resources/views/auth/register.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.base') 2 | @section('title', 'Create a new account') 3 | 4 | @section('body') 5 |
6 | @livewire('auth.register') 7 |
8 | @endsection 9 | -------------------------------------------------------------------------------- /resources/views/auth/verify.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.auth') 2 | @section('title', 'Verify your email address') 3 | 4 | @section('content') 5 |
6 | @livewire('auth.verify') 7 |
8 | @endsection 9 | -------------------------------------------------------------------------------- /resources/views/components/loading.blade.php: -------------------------------------------------------------------------------- 1 |
merge(['class' => 'la-line-scale la-dark']) }} > 2 |
3 |
4 |
5 |
6 |
7 |
8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /storage/*.key 5 | /vendor 6 | .env 7 | .env.backup 8 | .phpunit.result.cache 9 | Homestead.json 10 | Homestead.yaml 11 | npm-debug.log 12 | yarn-error.log 13 | -------------------------------------------------------------------------------- /resources/views/auth/passwords/email.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.auth') 2 | @section('title', 'Reset password') 3 | 4 | @section('content') 5 |
6 | @livewire('auth.passwords.email') 7 |
8 | @endsection 9 | -------------------------------------------------------------------------------- /resources/views/auth/passwords/confirm.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.auth') 2 | @section('title', 'Confirm your password') 3 | 4 | @section('content') 5 |
6 | @livewire('auth.passwords.confirm') 7 |
8 | @endsection 9 | -------------------------------------------------------------------------------- /stubs/controller.plain.stub: -------------------------------------------------------------------------------- 1 | 5 | @yield('content') 6 | 7 | @endsection 8 | -------------------------------------------------------------------------------- /app/Tenant.php: -------------------------------------------------------------------------------- 1 | 7 |
8 | 9 |
10 | @endsection 11 | -------------------------------------------------------------------------------- /app/Phone.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /resources/views/auth/passwords/reset.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.auth') 2 | @section('title', 'Reset password') 3 | 4 | @section('content') 5 |
6 | @livewire('auth.passwords.reset', [ 7 | 'token' => $token 8 | ]) 9 |
10 | @endsection 11 | -------------------------------------------------------------------------------- /stubs/seeder.stub: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /resources/views/dashboard.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('title', 'Dashboard') 4 | 5 | @section('content') 6 | 7 |
8 | 9 |
10 | 11 | @endsection 12 | 13 | -------------------------------------------------------------------------------- /app/Login.php: -------------------------------------------------------------------------------- 1 | define({{ model }}::class, function (Faker $faker) { 9 | return [ 10 | 'tenant_id' => factory(App\Tenant::class), 11 | ]; 12 | }); 13 | -------------------------------------------------------------------------------- /database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(DemoSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/Unit/ExampleTest.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /stubs/test.unit.stub: -------------------------------------------------------------------------------- 1 | assertTrue(true); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get(route('home'))->assertSuccessful(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/PasswordResetController.php: -------------------------------------------------------------------------------- 1 | $token, 13 | ]); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /stubs/policy.plain.stub: -------------------------------------------------------------------------------- 1 | Tenant::factory(), 17 | ]; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /stubs/middleware.stub: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | $this->faker->company, 16 | ]; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/Http/Middleware/CheckForMaintenanceMode.php: -------------------------------------------------------------------------------- 1 | allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /resources/views/components/desktop-nav-link.blade.php: -------------------------------------------------------------------------------- 1 | @props([ 2 | 'route', 3 | ]) 4 | 5 | 9 | {{$slot}} 10 | 11 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/LogoutController.php: -------------------------------------------------------------------------------- 1 | get('/'); 19 | 20 | $response->assertStatus(200); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class); 18 | } 19 | 20 | public function privateUrl() 21 | { 22 | return url('/documents/' . $this->user_id . '/' . $this->filename); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('login'); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | import 'alpinejs'; 2 | 3 | /** 4 | * Echo exposes an expressive API for subscribing to channels and listening 5 | * for events that are broadcast by Laravel. Echo and event broadcasting 6 | * allows your team to easily build robust real-time web applications. 7 | */ 8 | 9 | // import Echo from 'laravel-echo' 10 | 11 | // window.Pusher = require('pusher-js'); 12 | 13 | // window.Echo = new Echo({ 14 | // broadcaster: 'pusher', 15 | // key: process.env.MIX_PUSHER_APP_KEY, 16 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 17 | // forceTLS: true 18 | // }); 19 | -------------------------------------------------------------------------------- /stubs/request.stub: -------------------------------------------------------------------------------- 1 | has('tenant_id')) { 18 | $model->tenant_id = session()->get('tenant_id'); 19 | } 20 | }); 21 | } 22 | 23 | public function tenant() 24 | { 25 | return $this->belongsTo(Tenant::class); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/Http/Controllers/ImpersonationController.php: -------------------------------------------------------------------------------- 1 | has('impersonate')) { 14 | abort(403); 15 | } 16 | // login as the super user in session 17 | auth()->login(User::withoutGlobalScope(TenantScope::class)->find(session('impersonate'))); 18 | session()->forget('impersonate'); 19 | 20 | return redirect('/'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /app/Listeners/ClearTenantIdFromSession.php: -------------------------------------------------------------------------------- 1 | forget('tenant_id'); 18 | } 19 | 20 | /** 21 | * Handle the event. 22 | * 23 | * @param object $event 24 | * @return void 25 | */ 26 | public function handle($event) 27 | { 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Http/Livewire/Auth/Passwords/Confirm.php: -------------------------------------------------------------------------------- 1 | validate([ 15 | 'password' => 'required|password', 16 | ]); 17 | 18 | session()->put('auth.password_confirmed_at', time()); 19 | 20 | redirect()->intended(route('home')); 21 | } 22 | 23 | public function render() 24 | { 25 | return view('livewire.auth.passwords.confirm'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 18 | return $request->user(); 19 | }); 20 | -------------------------------------------------------------------------------- /app/Listeners/SetTenantIdInSession.php: -------------------------------------------------------------------------------- 1 | put('tenant_id', $event->user->tenant_id); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | swap(Mix::class, function () { 20 | return ''; 21 | }); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /database/factories/LoginFactory.php: -------------------------------------------------------------------------------- 1 | faker->dateTimeBetween('-6 hours', 'now'); 16 | return [ 17 | 'user_id' => User::factory(), 18 | 'tenant_id' => Tenant::factory(), 19 | 'created_at' => $randomDateTime, 20 | 'updated_at' => $randomDateTime, 21 | ]; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/Http/Livewire/Auth/Verify.php: -------------------------------------------------------------------------------- 1 | hasVerifiedEmail()) { 14 | redirect(route('home')); 15 | } 16 | 17 | Auth::user()->sendEmailVerificationNotification(); 18 | 19 | $this->emit('resent'); 20 | 21 | session()->flash('resent'); 22 | } 23 | 24 | public function render() 25 | { 26 | return view('livewire.auth.verify'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->describe('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Send Requests To Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 22 | return redirect(route('home')); 23 | } 24 | 25 | return $next($request); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/Scopes/TenantScope.php: -------------------------------------------------------------------------------- 1 | has('tenant_id')) { 21 | $builder->where('tenant_id', session()->get('tenant_id')); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | * 22 | * @return void 23 | */ 24 | public function boot() 25 | { 26 | $this->registerPolicies(); 27 | 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /stubs/migration.update.stub: -------------------------------------------------------------------------------- 1 | $this->name, 16 | 'tenant_id' => 4]); 17 | $this->success = true; 18 | } 19 | 20 | public function mount($departmentId = null) 21 | { 22 | if($departmentId) { 23 | $this->name = Department::findorfail($departmentId)->name; 24 | } 25 | } 26 | public function render() 27 | { 28 | return view('livewire.department-form'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /stubs/job.queued.stub: -------------------------------------------------------------------------------- 1 | register([ 30 | \App\Charts\LoginChart::class 31 | ]); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /resources/views/users/create.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('title', 'Create Team Member') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |
10 |

Personal Information

11 |

12 | The more the merrier! Create a new team member. 13 |

14 |
15 |
16 | 17 |
18 |
19 |
20 | 21 | @endsection 22 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require("laravel-mix"); 2 | 3 | require("laravel-mix-tailwind"); 4 | 5 | /* 6 | |-------------------------------------------------------------------------- 7 | | Mix Asset Management 8 | |-------------------------------------------------------------------------- 9 | | 10 | | Mix provides a clean, fluent API for defining some Webpack build steps 11 | | for your Laravel application. By default, we are compiling the Sass 12 | | file for the application as well as bundling up all the JS files. 13 | | 14 | */ 15 | 16 | mix.js("resources/js/app.js", "public/js/app.js") 17 | .sass("resources/sass/app.scss", "public/css/app.css") 18 | .tailwind("./tailwind.config.js") 19 | .sourceMaps(); 20 | 21 | if (mix.inProduction()) { 22 | mix.version(); 23 | } 24 | -------------------------------------------------------------------------------- /stubs/migration.create.stub: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->unsignedBigInteger('tenant_id')->index(); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('{{ table }}'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Listeners/RecordLogin.php: -------------------------------------------------------------------------------- 1 | user->tenant_id) { 30 | Login::create([ 31 | 'user_id' => $event->user->id, 32 | 'tenant_id' => $event->user->tenant_id, 33 | ]); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/migrations/2020_06_03_032546_create_tenants_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('name'); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('tenants'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2020_06_12_024233_create_phones_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->unsignedBigInteger('tenant_id'); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('phones'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /stubs/rule.stub: -------------------------------------------------------------------------------- 1 | 'Your password has been reset!', 17 | 'sent' => 'We have emailed your password reset link!', 18 | 'throttled' => 'Please wait before retrying.', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that email address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /app/Http/Controllers/DocumentController.php: -------------------------------------------------------------------------------- 1 | documents()->where('filename', $filename)->get()->first(); 15 | // authorise user making request 16 | if(! request()->user()->isAdmin()) { 17 | abort(403); 18 | } 19 | // stream the file to the browser 20 | if($document->extension == 'pdf') { 21 | return response(Storage::disk('s3')->get('/documents/' . $user->id . '/' . $filename)) 22 | ->header('Content-Type', 'application/pdf'); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /stubs/console.stub: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('name'); 19 | $table->unsignedBigInteger('tenant_id'); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('departments'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2020_08_02_155726_create_logins_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->unsignedBigInteger('user_id'); 19 | $table->unsignedBigInteger('tenant_id')->index(); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('logins'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Http/Controllers/HomeController.php: -------------------------------------------------------------------------------- 1 | check()) { 15 | return view('welcome'); 16 | } else { 17 | if(session()->has('tenant_id')) { 18 | return view('dashboard'); 19 | } 20 | $subscribersCount = Tenant::count(); 21 | $usersCount = User::count(); 22 | $loginsCount = Login::count(); 23 | return view('super.dashboard', [ 24 | 'subscribersCount' => $subscribersCount, 25 | 'usersCount' => $usersCount, 26 | 'loginsCount' => $loginsCount, 27 | ]); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tests/Feature/Auth/LogoutTest.php: -------------------------------------------------------------------------------- 1 | create(); 18 | $this->be($user); 19 | 20 | $this->post(route('logout')) 21 | ->assertRedirect(route('home')); 22 | 23 | $this->assertFalse(Auth::check()); 24 | } 25 | 26 | /** @test */ 27 | public function an_unauthenticated_user_can_not_log_out() 28 | { 29 | $this->post(route('logout')) 30 | ->assertRedirect(route('login')); 31 | 32 | $this->assertFalse(Auth::check()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/seeds/DemoSeeder.php: -------------------------------------------------------------------------------- 1 | count(3)->create(); 19 | 20 | foreach(Tenant::all() as $tenant) { 21 | User::factory()->count(20)->create([ 22 | 'tenant_id' => $tenant->id, 23 | ]); 24 | } 25 | 26 | foreach(User::all() as $user) { 27 | Login::factory()->count(5)->create([ 28 | 'user_id' => $user->id, 29 | 'tenant_id' => $user->tenant_id, 30 | ]); 31 | } 32 | User::factory()->count(1)->create([ 33 | 'tenant_id' => null, 34 | 'email' => 'admin@admin.com', 35 | ]); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /config/cors.php: -------------------------------------------------------------------------------- 1 | ['api/*'], 19 | 20 | 'allowed_methods' => ['*'], 21 | 22 | 'allowed_origins' => ['*'], 23 | 24 | 'allowed_origins_patterns' => [], 25 | 26 | 'allowed_headers' => ['*'], 27 | 28 | 'exposed_headers' => [], 29 | 30 | 'max_age' => 0, 31 | 32 | 'supports_credentials' => false, 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->text('connection'); 19 | $table->text('queue'); 20 | $table->longText('payload'); 21 | $table->longText('exception'); 22 | $table->timestamp('failed_at')->useCurrent(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('failed_jobs'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://teamsy.test 6 | 7 | LOG_CHANNEL=stack 8 | 9 | DB_CONNECTION=mysql 10 | DB_HOST=127.0.0.1 11 | DB_PORT=3306 12 | DB_DATABASE=teamsy 13 | DB_USERNAME=root 14 | DB_PASSWORD= 15 | 16 | BROADCAST_DRIVER=log 17 | CACHE_DRIVER=file 18 | QUEUE_CONNECTION=sync 19 | SESSION_DRIVER=file 20 | SESSION_LIFETIME=120 21 | 22 | REDIS_HOST=127.0.0.1 23 | REDIS_PASSWORD=null 24 | REDIS_PORT=6379 25 | 26 | MAIL_MAILER=smtp 27 | MAIL_HOST=smtp.mailtrap.io 28 | MAIL_PORT=2525 29 | MAIL_USERNAME=null 30 | MAIL_PASSWORD=null 31 | MAIL_ENCRYPTION=null 32 | MAIL_FROM_ADDRESS=null 33 | MAIL_FROM_NAME="${APP_NAME}" 34 | 35 | AWS_ACCESS_KEY_ID= 36 | AWS_SECRET_ACCESS_KEY= 37 | AWS_DEFAULT_REGION=us-east-1 38 | AWS_BUCKET= 39 | 40 | PUSHER_APP_ID= 41 | PUSHER_APP_KEY= 42 | PUSHER_APP_SECRET= 43 | PUSHER_APP_CLUSTER=mt1 44 | 45 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 46 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 47 | -------------------------------------------------------------------------------- /app/Http/Livewire/Auth/Login.php: -------------------------------------------------------------------------------- 1 | validate([ 23 | 'email' => ['required', 'email'], 24 | 'password' => ['required'], 25 | ]); 26 | 27 | if (!Auth::attempt($credentials, $this->remember)) { 28 | $this->addError('email', trans('auth.failed')); 29 | 30 | return; 31 | } 32 | 33 | redirect(route('home')); 34 | } 35 | 36 | public function render() 37 | { 38 | return view('livewire.auth.login'); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire')->hourly(); 28 | } 29 | 30 | /** 31 | * Register the commands for the application. 32 | * 33 | * @return void 34 | */ 35 | protected function commands() 36 | { 37 | $this->load(__DIR__.'/Commands'); 38 | 39 | require base_path('routes/console.php'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/Charts/LoginChart.php: -------------------------------------------------------------------------------- 1 | subHours(3), now()->subHours(2)])->count(), 25 | Login::whereBetween('created_at', [now()->subHours(2), now()->subHours(1)])->count(), 26 | Login::whereBetween('created_at', [now()->subHours(1), now()])->count(), 27 | ]; 28 | 29 | return Chartisan::build() 30 | ->labels(['Two Hours Ago', 'One Hour Ago', 'This Hour']) 31 | ->dataset('Logins', $logins); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/migrations/2020_07_30_045803_create_documents_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('type'); 19 | $table->unsignedBigInteger('user_id'); 20 | $table->string('filename'); 21 | $table->string('extension'); 22 | $table->integer('size'); 23 | $table->unsignedBigInteger('tenant_id')->index(); 24 | $table->timestamps(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::dropIfExists('documents'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | const defaultTheme = require('tailwindcss/defaultTheme'); 2 | 3 | module.exports = { 4 | theme: { 5 | extend: { 6 | fontFamily: { 7 | sans: ['Inter var', ...defaultTheme.fontFamily.sans], 8 | }, 9 | }, 10 | }, 11 | variants: {}, 12 | purge: { 13 | content: [ 14 | './app/**/*.php', 15 | './resources/**/*.html', 16 | './resources/**/*.js', 17 | './resources/**/*.jsx', 18 | './resources/**/*.ts', 19 | './resources/**/*.tsx', 20 | './resources/**/*.php', 21 | './resources/**/*.vue', 22 | './resources/**/*.twig', 23 | ], 24 | options: { 25 | defaultExtractor: (content) => content.match(/[\w-/.:]+(? 2 | 3 | 4 | 5 | 6 | 7 | @hasSection('title') 8 | @yield('title') - {{ config('app.name') }} 9 | @else 10 | {{ config('app.name') }} 11 | @endif 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | @livewireStyles 22 | 23 | 24 | 25 | 26 | 27 | 28 | @yield('body') 29 | @stack('scripts') 30 | 31 | @livewireScripts 32 | 33 | 34 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | ], 22 | 23 | 'postmark' => [ 24 | 'token' => env('POSTMARK_TOKEN'), 25 | ], 26 | 27 | 'ses' => [ 28 | 'key' => env('AWS_ACCESS_KEY_ID'), 29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 31 | ], 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/EmailVerificationController.php: -------------------------------------------------------------------------------- 1 | getKey())) { 17 | throw new AuthorizationException(); 18 | } 19 | 20 | if (!hash_equals((string) $hash, sha1(Auth::user()->getEmailForVerification()))) { 21 | throw new AuthorizationException(); 22 | } 23 | 24 | if (Auth::user()->hasVerifiedEmail()) { 25 | return redirect(route('home')); 26 | } 27 | 28 | if (Auth::user()->markEmailAsVerified()) { 29 | event(new Verified(Auth::user())); 30 | } 31 | 32 | return redirect(route('home')); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /app/Http/Livewire/Auth/Passwords/Email.php: -------------------------------------------------------------------------------- 1 | validate([ 19 | 'email' => ['required', 'email'], 20 | ]); 21 | 22 | $response = $this->broker()->sendResetLink(['email' => $this->email]); 23 | 24 | if ($response == Password::RESET_LINK_SENT) { 25 | $this->emailSentMessage = trans($response); 26 | 27 | return; 28 | } 29 | 30 | $this->addError('email', trans($response)); 31 | } 32 | 33 | /** 34 | * Get the broker to be used during password reset. 35 | * 36 | * @return \Illuminate\Contracts\Auth\PasswordBroker 37 | */ 38 | public function broker() 39 | { 40 | return Password::broker(); 41 | } 42 | 43 | public function render() 44 | { 45 | return view('livewire.auth.passwords.email'); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 6 | "watch": "npm run development -- --watch", 7 | "watch-poll": "npm run watch -- --watch-poll", 8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js", 9 | "prod": "npm run production", 10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" 11 | }, 12 | "devDependencies": { 13 | "@tailwindcss/custom-forms": "^0.2", 14 | "@tailwindcss/ui": "^0.1", 15 | "alpinejs": "^2.0", 16 | "cross-env": "^7.0", 17 | "laravel-mix": "^5.0.1", 18 | "laravel-mix-tailwind": "^0.1.0", 19 | "resolve-url-loader": "^3.1.0", 20 | "sass": "^1.15.2", 21 | "sass-loader": "^8.0.0", 22 | "tailwindcss": "^1.4", 23 | "vue-template-compiler": "^2.6.11" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->string('role'); 21 | $table->string('photo')->nullable(); 22 | $table->string('department')->nullable(); 23 | $table->string('title')->nullable(); 24 | $table->boolean('status')->default(1); 25 | $table->timestamp('email_verified_at')->nullable(); 26 | $table->string('password'); 27 | $table->rememberToken(); 28 | $table->timestamps(); 29 | $table->unsignedBigInteger('tenant_id')->nullable(); 30 | }); 31 | } 32 | 33 | /** 34 | * Reverse the migrations. 35 | * 36 | * @return void 37 | */ 38 | public function down() 39 | { 40 | Schema::dropIfExists('users'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | ./tests/Unit 10 | 11 | 12 | ./tests/Feature 13 | 14 | 15 | 16 | 17 | ./app 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 24 | SendEmailVerificationNotification::class, 25 | ], 26 | \Illuminate\Auth\Events\Login::class => [ 27 | SetTenantIdInSession::class, 28 | RecordLogin::class, 29 | ], 30 | Logout::class => [ 31 | ClearTenantIdFromSession::class, 32 | ] 33 | ]; 34 | 35 | /** 36 | * Register any events for your application. 37 | * 38 | * @return void 39 | */ 40 | public function boot() 41 | { 42 | parent::boot(); 43 | 44 | // 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | $this->faker->name, 28 | 'email' => $this->faker->unique()->safeEmail, 29 | 'role' => 'Admin', 30 | 'photo' => null, 31 | 'department' => $this->faker->sentence(2), 32 | 'title' => $this->faker->jobTitle, 33 | 'status' => 1, 34 | 'email_verified_at' => now(), 35 | 'password' => bcrypt('password'), 36 | 'remember_token' => Str::random(10), 37 | 'tenant_id' => Tenant::factory(), 38 | ]; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 |

2 | 3 | ## About Teamsy 4 | 5 | Teamsy is a single database multi tenant application shell built for the Laracasts series "Single Database Multi Tenancy". 6 | 7 | Use the "Lessons" section below to find the branch that corresponds to each lesson, or just clone the master branch to see the finished product. 8 | 9 | Feel free to use this as a starting point for your next multi tenant application. 10 | 11 | Interact with me on [Twitter](https://twitter.com/iAmKevinMcKee) or open an issue or PR if you'd like to contribute to this project. 12 | 13 | ## Installation 14 | 15 | Clone this repo to get started. 16 | 17 | `git clone https://github.com/iAmKevinMcKee/teamsy.git` 18 | 19 | Install Composer Dependencies 20 | 21 | `composer install` 22 | 23 | Install NPM Dependencies 24 | 25 | `npm install && npm run dev` 26 | 27 | Copy the .env.example file to .env 28 | 29 | `cp .env.example .env` 30 | 31 | Update your .env file to connect to your local database. 32 | 33 | Generate your application keys 34 | 35 | `php artisan key:generate` 36 | 37 | Run the Demo Seeder to get started with a few tenants and some users 38 | 39 | `php artisan migrate:fresh --seed` 40 | 41 | Login to the app on your local maching using the following credentials: 42 | 43 | admin@admin.com / password 44 | 45 | ## License 46 | 47 | This project is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). 48 | -------------------------------------------------------------------------------- /resources/views/components/th.blade.php: -------------------------------------------------------------------------------- 1 | @props([ 2 | 'value' => '', 3 | 'label' => '', 4 | 'canSort' => false, 5 | 'sortField' => '', 6 | 'sortAsc' => '', 7 | ]) 8 | 9 | 10 | {{$label}} 11 | @if($canSort) 12 | @if($sortField === $value) 13 | @if($sortAsc) 14 | 15 | @else 16 | 17 | @endif 18 | @else 19 | 20 | @endif 21 | @endif 22 | 23 | 24 | -------------------------------------------------------------------------------- /public/img/logos/workflow-mark-on-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /tests/Feature/Auth/Passwords/EmailTest.php: -------------------------------------------------------------------------------- 1 | get(route('password.request')) 18 | ->assertSuccessful() 19 | ->assertSeeLivewire('auth.passwords.email'); 20 | } 21 | 22 | /** @test */ 23 | public function a_user_must_enter_an_email_address() 24 | { 25 | Livewire::test('auth.passwords.email') 26 | ->call('sendResetPasswordLink') 27 | ->assertHasErrors(['email' => 'required']); 28 | } 29 | 30 | /** @test */ 31 | public function a_user_must_enter_a_valid_email_address() 32 | { 33 | Livewire::test('auth.passwords.email') 34 | ->set('email', 'email') 35 | ->call('sendResetPasswordLink') 36 | ->assertHasErrors(['email' => 'email']); 37 | } 38 | 39 | /** @test */ 40 | public function a_user_who_enters_a_valid_email_address_will_get_sent_an_email() 41 | { 42 | $user = factory(User::class)->create(); 43 | 44 | Livewire::test('auth.passwords.email') 45 | ->set('email', $user->email) 46 | ->call('sendResetPasswordLink') 47 | ->assertNotSet('emailSentMessage', false); 48 | 49 | $this->assertDatabaseHas('password_resets', [ 50 | 'email' => $user->email, 51 | ]); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/Http/Livewire/Auth/Register.php: -------------------------------------------------------------------------------- 1 | validate([ 28 | 'name' => ['required', 'string'], 29 | 'companyName' => ['required', 'string', 'unique:tenants,name'], 30 | 'email' => ['required', 'email', 'unique:users'], 31 | 'password' => ['required', 'min:8'], 32 | ]); 33 | 34 | $tenant = Tenant::create([ 35 | 'name' => $this->companyName, 36 | ]); 37 | 38 | $user = User::create([ 39 | 'email' => $this->email, 40 | 'name' => $this->name, 41 | 'role' => 'Admin', 42 | 'password' => Hash::make($this->password), 43 | 'tenant_id' => $tenant->id, 44 | ]); 45 | 46 | $user->sendEmailVerificationNotification(); 47 | 48 | Auth::login($user, true); 49 | 50 | redirect(route('home')); 51 | } 52 | 53 | public function updated($value) { 54 | $this->resetErrorBag($value); 55 | } 56 | 57 | public function render() 58 | { 59 | return view('livewire.auth.register'); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /stubs/controller.model.api.stub: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 1024, 48 | 'threads' => 2, 49 | 'time' => 2, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /resources/views/vendor/pagination/simple-default.blade.php: -------------------------------------------------------------------------------- 1 | @if ($paginator->hasPages()) 2 | 25 | @endif 26 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'useTLS' => true, 41 | ], 42 | ], 43 | 44 | 'redis' => [ 45 | 'driver' => 'redis', 46 | 'connection' => 'default', 47 | ], 48 | 49 | 'log' => [ 50 | 'driver' => 'log', 51 | ], 52 | 53 | 'null' => [ 54 | 'driver' => 'null', 55 | ], 56 | 57 | ], 58 | 59 | ]; 60 | -------------------------------------------------------------------------------- /app/Http/Livewire/ShowUsers.php: -------------------------------------------------------------------------------- 1 | sortField === $field) { 25 | $this->sortAsc = ! $this->sortAsc; 26 | } else { 27 | $this->sortAsc = true; 28 | } 29 | 30 | $this->sortField = $field; 31 | } 32 | 33 | public function impersonate($userId) 34 | { 35 | if(! is_null(auth()->user()->tenant_id)) { 36 | return; 37 | } 38 | 39 | $originalId = auth()->user()->id; 40 | session()->put('impersonate', $originalId); 41 | auth()->loginUsingId($userId); 42 | 43 | return redirect('/team'); 44 | } 45 | 46 | public function mount() 47 | { 48 | if(session()->has('tenant_id')) { 49 | $this->super = false; 50 | } else { 51 | $this->super = true; 52 | $this->tenants = Tenant::all()->pluck('name', 'id')->toArray(); 53 | } 54 | } 55 | 56 | public function render() 57 | { 58 | $query = User::search($this->search) 59 | ->orderBy($this->sortField, $this->sortAsc ? 'asc' : 'desc'); 60 | if($this->super && $this->selectedTenant) { 61 | $query->where('tenant_id', $this->selectedTenant); 62 | } 63 | 64 | return view('livewire.show-users', [ 65 | 'users' => $query->with('documents')->paginate($this->perPage), 66 | ]); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /tests/Feature/Auth/VerifyTest.php: -------------------------------------------------------------------------------- 1 | create([ 24 | 'email_verified_at' => null, 25 | ]); 26 | 27 | Auth::login($user); 28 | 29 | $this->get(route('verification.notice')) 30 | ->assertSuccessful() 31 | ->assertSeeLivewire('auth.verify'); 32 | } 33 | 34 | /** @test */ 35 | public function can_resend_verification_email() 36 | { 37 | $user = factory(User::class)->create(); 38 | 39 | Livewire::actingAs($user); 40 | 41 | Livewire::test('auth.verify') 42 | ->call('resend') 43 | ->assertEmitted('resent'); 44 | } 45 | 46 | /** @test */ 47 | public function can_verify() 48 | { 49 | $user = factory(User::class)->create([ 50 | 'email_verified_at' => null, 51 | ]); 52 | 53 | Auth::login($user); 54 | 55 | $url = URL::temporarySignedRoute('verification.verify', Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)), [ 56 | 'id' => $user->getKey(), 57 | 'hash' => sha1($user->getEmailForVerification()), 58 | ]); 59 | 60 | $this->get($url) 61 | ->assertRedirect(route('home')); 62 | 63 | $this->assertTrue($user->hasVerifiedEmail()); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /stubs/controller.stub: -------------------------------------------------------------------------------- 1 | mapApiRoutes(); 46 | 47 | $this->mapWebRoutes(); 48 | 49 | // 50 | } 51 | 52 | /** 53 | * Define the "web" routes for the application. 54 | * 55 | * These routes all receive session state, CSRF protection, etc. 56 | * 57 | * @return void 58 | */ 59 | protected function mapWebRoutes() 60 | { 61 | Route::middleware('web') 62 | ->namespace($this->namespace) 63 | ->group(base_path('routes/web.php')); 64 | } 65 | 66 | /** 67 | * Define the "api" routes for the application. 68 | * 69 | * These routes are typically stateless. 70 | * 71 | * @return void 72 | */ 73 | protected function mapApiRoutes() 74 | { 75 | Route::prefix('api') 76 | ->middleware('api') 77 | ->namespace($this->namespace) 78 | ->group(base_path('routes/api.php')); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | define('LARAVEL_START', microtime(true)); 11 | 12 | /* 13 | |-------------------------------------------------------------------------- 14 | | Register The Auto Loader 15 | |-------------------------------------------------------------------------- 16 | | 17 | | Composer provides a convenient, automatically generated class loader for 18 | | our application. We just need to utilize it! We'll simply require it 19 | | into the script here so that we don't have to worry about manual 20 | | loading any of our classes later on. It feels great to relax. 21 | | 22 | */ 23 | 24 | require __DIR__.'/../vendor/autoload.php'; 25 | 26 | /* 27 | |-------------------------------------------------------------------------- 28 | | Turn On The Lights 29 | |-------------------------------------------------------------------------- 30 | | 31 | | We need to illuminate PHP development, so let us turn on the lights. 32 | | This bootstraps the framework and gets it ready for use, then it 33 | | will load up this application so that we can run it and send 34 | | the responses back to the browser and delight our users. 35 | | 36 | */ 37 | 38 | $app = require_once __DIR__.'/../bootstrap/app.php'; 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Run The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once we have the application, we can handle the incoming request 46 | | through the kernel, and send the associated response back to 47 | | the client's browser allowing them to enjoy the creative 48 | | and wonderful application we have prepared for them. 49 | | 50 | */ 51 | 52 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); 53 | 54 | $response = $kernel->handle( 55 | $request = Illuminate\Http\Request::capture() 56 | ); 57 | 58 | $response->send(); 59 | 60 | $kernel->terminate($request, $response); 61 | -------------------------------------------------------------------------------- /resources/views/components/logo.blade.php: -------------------------------------------------------------------------------- 1 | 2 | {{ config('app.name') }} 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/views/components/text-input.blade.php: -------------------------------------------------------------------------------- 1 | @props([ 2 | 'type' => "text", 3 | 'label' => "", 4 | 'placeholder' => "", 5 | ]) 6 | 7 |
8 | 11 |
12 | whereStartsWith('wire:model')}} 14 | id="{{$attributes->whereStartsWith('wire:model')->first()}}" 15 | type="{{$type}}" 16 | @error($attributes->whereStartsWith('wire:model')->first()) 17 | class="form-input block w-full pr-10 border-red-300 text-red-900 placeholder-red-300 focus:border-red-300 focus:shadow-outline-red sm:text-sm sm:leading-5" 18 | @else 19 | class="form-input block w-full sm:text-sm sm:leading-5" 20 | @endif 21 | placeholder="{{$placeholder}}" 22 | @error($attributes->whereStartsWith('wire:model')->first()) 23 | aria-invalid="true" 24 | aria-describedby="email-error" 25 | @enderror 26 | /> 27 | @error($attributes->whereStartsWith('wire:model')->first()) 28 |
30 | 31 | 32 | 33 |
34 | @enderror 35 |
36 | @error($attributes->whereStartsWith('wire:model')->first()) 37 |

{{$message}} 38 |

39 | @enderror 40 |
41 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The Laravel Framework.", 5 | "keywords": [ 6 | "framework", 7 | "laravel" 8 | ], 9 | "license": "MIT", 10 | "require": { 11 | "php": "^7.2.5", 12 | "consoletvs/charts": "7.*", 13 | "fideloper/proxy": "^4.2", 14 | "fruitcake/laravel-cors": "^1.0", 15 | "guzzlehttp/guzzle": "^7.0.1", 16 | "laravel-frontend-presets/tall": "^1.7", 17 | "laravel/framework": "^8.0", 18 | "laravel/tinker": "^2.0", 19 | "league/flysystem-aws-s3-v3": "^1.0", 20 | "livewire/livewire": "^1.1" 21 | }, 22 | "require-dev": { 23 | "barryvdh/laravel-debugbar": "^3.3", 24 | "facade/ignition": "^2.3.6", 25 | "fzaninotto/faker": "^1.9.1", 26 | "mockery/mockery": "^1.3.1", 27 | "nunomaduro/collision": "^5.0", 28 | "phpunit/phpunit": "^9.0" 29 | }, 30 | "config": { 31 | "optimize-autoloader": true, 32 | "preferred-install": "dist", 33 | "sort-packages": true 34 | }, 35 | "extra": { 36 | "laravel": { 37 | "dont-discover": [] 38 | } 39 | }, 40 | "autoload": { 41 | "psr-4": { 42 | "App\\": "app/", 43 | "Database\\Factories\\": "database/factories/", 44 | "Database\\Seeders\\": "database/seeders/" 45 | }, 46 | "classmap": [ 47 | "database/seeds", 48 | "database/factories" 49 | ] 50 | }, 51 | "autoload-dev": { 52 | "psr-4": { 53 | "Tests\\": "tests/" 54 | } 55 | }, 56 | "minimum-stability": "dev", 57 | "prefer-stable": true, 58 | "scripts": { 59 | "post-autoload-dump": [ 60 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 61 | "@php artisan package:discover --ansi" 62 | ], 63 | "post-root-package-install": [ 64 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 65 | ], 66 | "post-create-project-cmd": [ 67 | "@php artisan key:generate --ansi" 68 | ] 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /stubs/controller.model.stub: -------------------------------------------------------------------------------- 1 | whereNotNull('tenant_id')->get(); 20 | foreach($users as $user) { 21 | factory(App\Login::class, 1)->create([ 22 | 'user_id' => $user->id, 23 | 'tenant_id' => $user->tenant_id, 24 | 'created_at' => now(), 25 | ]); 26 | } 27 | return 'loaded'; 28 | }); 29 | 30 | Route::get('/', [HomeController::class, 'show'])->name('home'); 31 | 32 | Route::middleware('guest')->group(function () { 33 | Route::view('login', 'auth.login')->name('login'); 34 | Route::view('register', 'auth.register')->name('register'); 35 | }); 36 | 37 | Route::view('password/reset', 'auth.passwords.email')->name('password.request'); 38 | Route::get('password/reset/{token}', 'Auth\PasswordResetController')->name('password.reset'); 39 | 40 | Route::middleware('auth')->group(function () { 41 | Route::get('/leave-impersonation', [\App\Http\Controllers\ImpersonationController::class, 'leave'])->name('leave-impersonation'); 42 | 43 | Route::view('/team', 'team')->name('team.index'); 44 | Route::view('/team/add-user', 'users.create')->name('users.create'); 45 | 46 | Route::view('email/verify', 'auth.verify')->middleware('throttle:6,1')->name('verification.notice'); 47 | Route::get('email/verify/{id}/{hash}', 'Auth\EmailVerificationController')->middleware('signed')->name('verification.verify'); 48 | 49 | Route::get('logout', 'Auth\LogoutController')->name('logout'); 50 | 51 | Route::view('password/confirm', 'auth.passwords.confirm')->name('password.confirm'); 52 | Route::get('/documents/{user}/{filename}', [DocumentController::class, 'show']); 53 | }); 54 | -------------------------------------------------------------------------------- /app/User.php: -------------------------------------------------------------------------------- 1 | 'datetime', 42 | ]; 43 | 44 | public function avatarUrl() 45 | { 46 | if($this->photo) { 47 | return Storage::disk('s3-public')->url($this->photo); 48 | } 49 | return 'https://avatars.dicebear.com/api/initials/' . $this->name . '.svg'; 50 | } 51 | 52 | public static function search($query) 53 | { 54 | return empty($query) ? static::query() 55 | : static::where('name', 'like', '%'.$query.'%') 56 | ->orWhere('email', 'like', '%'.$query.'%'); 57 | } 58 | 59 | public function isAdmin() 60 | { 61 | return $this->role == 'Admin'; 62 | } 63 | 64 | public function isHR() 65 | { 66 | return $this->role == 'Human Resources'; 67 | } 68 | 69 | public function applicationUrl() 70 | { 71 | if($this->application()) { 72 | return url('/documents/' . $this->id . '/' . $this->application()->filename); 73 | } 74 | return '#'; 75 | } 76 | 77 | public function application() 78 | { 79 | return $this->documents()->where('type', 'application')->first(); 80 | } 81 | 82 | public function documents() 83 | { 84 | return $this->hasMany(Document::class); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /resources/views/livewire/auth/verify.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 | 6 | 7 |

8 | Verify your email address 9 |

10 | 11 |

12 | Or 13 | 14 | sign out 15 | 16 | 17 |

20 |

21 |
22 | 23 |
24 |
25 | @if (session('resent')) 26 | 33 | @endif 34 | 35 |
36 |

Before proceeding, please check your email for a verification link.

37 | 38 |

39 | If you did not receive the email, click here to request another. 40 |

41 |
42 |
43 |
44 |
45 | -------------------------------------------------------------------------------- /stubs/controller.nested.api.stub: -------------------------------------------------------------------------------- 1 | validate([ 26 | 'name' => 'required|string', 27 | 'email' => 'required|email|unique:users', 28 | 'department' => 'required|string', 29 | 'title' => 'required|string', 30 | 'status' => 'required|boolean', 31 | 'role' => 'required|string', 32 | 'photo' => 'image|max:1024', // 1MB Max 33 | 'application' => 'file|mimes:pdf|max:10000', 34 | ]); 35 | 36 | $filename = $this->photo->store('photos', 's3-public'); 37 | 38 | $user = User::create([ 39 | 'name' => $this->name, 40 | 'email' => $this->email, 41 | 'department' => $this->department, 42 | 'title' => $this->title, 43 | 'status' => $this->status, 44 | 'role' => $this->role, 45 | 'photo' => $filename, 46 | 'password' => bcrypt(Str::random(16)), 47 | ]); 48 | 49 | // filename - docname_1773271717732.pdf 50 | $filename = pathinfo($this->application->getClientOriginalName(), PATHINFO_FILENAME) 51 | . '_' . now()->timestamp . '.' . $this->application->getClientOriginalExtension(); 52 | 53 | // store private s3 54 | $this->application->storeAs('/documents/' . $user->id . '/', $filename, 's3'); 55 | 56 | // create document in db 57 | $user->documents()->create([ 58 | 'type' => 'application', 59 | 'filename' => $filename, 60 | 'extension' => $this->application->getClientOriginalExtension(), 61 | 'size' => $this->application->getSize(), 62 | ]); 63 | 64 | return redirect('/team'); 65 | } 66 | 67 | public function render() 68 | { 69 | return view('livewire.add-user'); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /tests/Feature/Auth/Passwords/ConfirmTest.php: -------------------------------------------------------------------------------- 1 | middleware(['web', 'password.confirm']); 23 | } 24 | 25 | /** @test */ 26 | public function a_user_must_confirm_their_password_before_visiting_a_protected_page() 27 | { 28 | $user = factory(User::class)->create(); 29 | $this->be($user); 30 | 31 | $this->get('/must-be-confirmed') 32 | ->assertRedirect(route('password.confirm')); 33 | 34 | $this->followingRedirects() 35 | ->get('/must-be-confirmed') 36 | ->assertSeeLivewire('auth.passwords.confirm'); 37 | } 38 | 39 | /** @test */ 40 | public function a_user_must_enter_a_password_to_confirm_it() 41 | { 42 | Livewire::test('auth.passwords.confirm') 43 | ->call('confirm') 44 | ->assertHasErrors(['password' => 'required']); 45 | } 46 | 47 | /** @test */ 48 | public function a_user_must_enter_their_own_password_to_confirm_it() 49 | { 50 | $user = factory(User::class)->create([ 51 | 'password' => Hash::make('password'), 52 | ]); 53 | 54 | Livewire::test('auth.passwords.confirm') 55 | ->set('password', 'not-password') 56 | ->call('confirm') 57 | ->assertHasErrors(['password' => 'password']); 58 | } 59 | 60 | /** @test */ 61 | public function a_user_who_confirms_their_password_will_get_redirected() 62 | { 63 | $user = factory(User::class)->create([ 64 | 'password' => Hash::make('password'), 65 | ]); 66 | 67 | $this->be($user); 68 | 69 | $this->withSession(['url.intended' => '/must-be-confirmed']); 70 | 71 | Livewire::test('auth.passwords.confirm') 72 | ->set('password', 'password') 73 | ->call('confirm') 74 | ->assertRedirect('/must-be-confirmed'); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/Http/Livewire/Auth/Passwords/Reset.php: -------------------------------------------------------------------------------- 1 | token = $token; 30 | } 31 | 32 | public function resetPassword() 33 | { 34 | $this->validate([ 35 | 'token' => 'required', 36 | 'email' => 'required|email', 37 | 'password' => 'required|min:8|same:passwordConfirmation', 38 | ]); 39 | 40 | $response = $this->broker()->reset( 41 | [ 42 | 'token' => $this->token, 43 | 'email' => $this->email, 44 | 'password' => $this->password 45 | ], 46 | function ($user, $password) { 47 | $user->password = Hash::make($password); 48 | 49 | $user->setRememberToken(Str::random(60)); 50 | 51 | $user->save(); 52 | 53 | event(new PasswordReset($user)); 54 | 55 | $this->guard()->login($user); 56 | } 57 | ); 58 | 59 | if ($response == Password::PASSWORD_RESET) { 60 | session()->flash(trans($response)); 61 | 62 | return redirect(route('home')); 63 | } 64 | 65 | $this->addError('email', trans($response)); 66 | } 67 | 68 | /** 69 | * Get the broker to be used during password reset. 70 | * 71 | * @return \Illuminate\Contracts\Auth\PasswordBroker 72 | */ 73 | public function broker() 74 | { 75 | return Password::broker(); 76 | } 77 | 78 | /** 79 | * Get the guard to be used during password reset. 80 | * 81 | * @return \Illuminate\Contracts\Auth\StatefulGuard 82 | */ 83 | protected function guard() 84 | { 85 | return Auth::guard(); 86 | } 87 | 88 | public function render() 89 | { 90 | return view('livewire.auth.passwords.reset'); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /resources/views/components/login-chart.blade.php: -------------------------------------------------------------------------------- 1 |
12 |
13 |
14 |
15 |

16 | Logins Last 3 Hours 17 |

18 |
19 |
20 | 21 | 27 | 28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | 36 | @push('scripts') 37 | 38 | 39 | 40 | 41 | @endpush 42 | -------------------------------------------------------------------------------- /stubs/policy.stub: -------------------------------------------------------------------------------- 1 | [ 33 | \App\Http\Middleware\EncryptCookies::class, 34 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 35 | \Illuminate\Session\Middleware\StartSession::class, 36 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 37 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 38 | \App\Http\Middleware\VerifyCsrfToken::class, 39 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 40 | ], 41 | 42 | 'api' => [ 43 | 'throttle:60,1', 44 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 45 | ], 46 | ]; 47 | 48 | /** 49 | * The application's route middleware. 50 | * 51 | * These middleware may be assigned to groups or used individually. 52 | * 53 | * @var array 54 | */ 55 | protected $routeMiddleware = [ 56 | 'auth' => \App\Http\Middleware\Authenticate::class, 57 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 58 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 59 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 60 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 61 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 62 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 63 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 64 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 65 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 66 | ]; 67 | } 68 | -------------------------------------------------------------------------------- /resources/views/livewire/auth/passwords/confirm.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 | 6 | 7 |

8 | Confirm your password 9 |

10 |

11 | Please confirm your password before continuing 12 |

13 |
14 | 15 |
16 |
17 |
18 |
19 | 22 | 23 |
24 | 25 |
26 | 27 | @error('password') 28 |

{{ $message }}

29 | @enderror 30 |
31 | 32 | 39 | 40 |
41 | 42 | 45 | 46 |
47 |
48 |
49 |
50 |
51 | -------------------------------------------------------------------------------- /public/img/logos/workflow-logo-on-dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /stubs/controller.nested.stub: -------------------------------------------------------------------------------- 1 | artisan('make:model Test -m'); 20 | 21 | // find the migration file and check it has a tenant_id on it 22 | $filename = $now->year . '_' . $now->format('m') . '_' . $now->format('d') . '_' . $now->format('H') 23 | . $now->format('i') . $now->format('s') . 24 | '_create_tests_table.php'; 25 | $this->assertTrue(File::exists(database_path('migrations/'.$filename))); 26 | $this->assertStringContainsString('$table->unsignedBigInteger(\'tenant_id\')->index();', 27 | File::get(database_path('migrations/'.$filename))); 28 | // clean up 29 | File::delete(database_path('migrations/'.$filename)); 30 | File::delete(app_path('Test.php')); 31 | } 32 | 33 | /** @test */ 34 | public function a_user_can_only_see_users_in_the_same_tenant() 35 | { 36 | $tenant1 = factory(Tenant::class)->create(); 37 | $tenant2 = factory(Tenant::class)->create(); 38 | 39 | $user1 = factory(User::class)->create([ 40 | 'tenant_id' => $tenant1, 41 | ]); 42 | 43 | factory(User::class, 9)->create([ 44 | 'tenant_id' => $tenant1, 45 | ]); 46 | 47 | factory(User::class, 10)->create([ 48 | 'tenant_id' => $tenant2, 49 | ]); 50 | 51 | auth()->login($user1); 52 | 53 | $this->assertEquals(10, User::count()); 54 | } 55 | 56 | /** @test */ 57 | public function test_a_user_can_only_create_a_user_in_his_tenant() 58 | { 59 | $tenant1 = factory(Tenant::class)->create(); 60 | $tenant2 = factory(Tenant::class)->create(); 61 | 62 | $user1 = factory(User::class)->create([ 63 | 'tenant_id' => $tenant1, 64 | ]); 65 | 66 | auth()->login($user1); 67 | 68 | $createdUser = factory(User::class)->create(); 69 | 70 | $this->assertTrue($createdUser->tenant_id == $user1->tenant_id); 71 | } 72 | 73 | /** @test */ 74 | public function test_a_user_can_only_create_a_user_in_his_tenant_even_if_other_tenant_is_provided() 75 | { 76 | $tenant1 = factory(Tenant::class)->create(); 77 | $tenant2 = factory(Tenant::class)->create(); 78 | 79 | $user1 = factory(User::class)->create([ 80 | 'tenant_id' => $tenant1, 81 | ]); 82 | 83 | auth()->login($user1); 84 | 85 | $createdUser = factory(User::class)->make(); 86 | $createdUser->tenant_id = $tenant2->id; 87 | $createdUser->save(); 88 | 89 | $this->assertTrue($createdUser->tenant_id == $user1->tenant_id); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'sync'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection information for each server that 24 | | is used by your application. A default configuration has been added 25 | | for each back-end shipped with Laravel. You are free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'retry_after' => 90, 42 | ], 43 | 44 | 'beanstalkd' => [ 45 | 'driver' => 'beanstalkd', 46 | 'host' => 'localhost', 47 | 'queue' => 'default', 48 | 'retry_after' => 90, 49 | 'block_for' => 0, 50 | ], 51 | 52 | 'sqs' => [ 53 | 'driver' => 'sqs', 54 | 'key' => env('AWS_ACCESS_KEY_ID'), 55 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 56 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 57 | 'queue' => env('SQS_QUEUE', 'your-queue-name'), 58 | 'suffix' => env('SQS_SUFFIX'), 59 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 60 | ], 61 | 62 | 'redis' => [ 63 | 'driver' => 'redis', 64 | 'connection' => 'default', 65 | 'queue' => env('REDIS_QUEUE', 'default'), 66 | 'retry_after' => 90, 67 | 'block_for' => null, 68 | ], 69 | 70 | ], 71 | 72 | /* 73 | |-------------------------------------------------------------------------- 74 | | Failed Queue Jobs 75 | |-------------------------------------------------------------------------- 76 | | 77 | | These options configure the behavior of failed queue job logging so you 78 | | can control which database and table are used to store the jobs that 79 | | have failed. You may change them to any database / table you wish. 80 | | 81 | */ 82 | 83 | 'failed' => [ 84 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database'), 85 | 'database' => env('DB_CONNECTION', 'mysql'), 86 | 'table' => 'failed_jobs', 87 | ], 88 | 89 | ]; 90 | -------------------------------------------------------------------------------- /resources/views/livewire/auth/passwords/email.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 | 6 | 7 |

8 | Reset password 9 |

10 |
11 | 12 |
13 |
14 | @if ($emailSentMessage) 15 |
16 |
17 |
18 | 19 | 20 | 21 |
22 | 23 |
24 |

25 | {{ $emailSentMessage }} 26 |

27 |
28 |
29 |
30 | @else 31 |
32 |
33 | 36 | 37 |
38 | 39 |
40 | 41 | @error('email') 42 |

{{ $message }}

43 | @enderror 44 |
45 | 46 |
47 | 48 | 51 | 52 |
53 |
54 | @endif 55 |
56 |
57 |
58 | -------------------------------------------------------------------------------- /resources/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('body') 4 |
5 |
6 |
7 | 10 | 11 | 12 |
13 |
14 |

15 | Data to enrich your 16 |
17 | online business 18 | 19 |

20 |

21 | Anim aute id magna aliqua ad ad non deserunt sunt. Qui irure qui lorem cupidatat commodo. Elit sunt amet fugiat veniam occaecat fugiat aliqua. 22 |

23 | 35 |
36 |
37 |
38 |
39 |
40 | 41 |
42 |
43 | @endsection 44 | -------------------------------------------------------------------------------- /resources/views/livewire/auth/register.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
6 | Workflow 7 |

8 | Start your free trial 9 |

10 |
11 | 12 |
13 |
14 |
15 | 22 | 29 | 36 | 43 | 44 |
45 | 46 | 49 | 50 |
51 | 52 |
53 |
54 |
55 |
56 | 59 |
60 |
61 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DRIVER', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Cloud Filesystem Disk 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Many applications store files both locally and in the cloud. For this 24 | | reason, you may specify a default "cloud" driver here. This driver 25 | | will be bound as the Cloud disk implementation in the container. 26 | | 27 | */ 28 | 29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Filesystem Disks 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here you may configure as many filesystem "disks" as you wish, and you 37 | | may even configure multiple disks of the same driver. Defaults have 38 | | been setup for each driver as an example of the required options. 39 | | 40 | | Supported Drivers: "local", "ftp", "sftp", "s3" 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'public' => [ 52 | 'driver' => 'local', 53 | 'root' => storage_path('app/public'), 54 | 'url' => env('APP_URL').'/storage', 55 | 'visibility' => 'public', 56 | ], 57 | 58 | 's3' => [ 59 | 'driver' => 's3', 60 | 'key' => env('AWS_ACCESS_KEY_ID'), 61 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 62 | 'region' => env('AWS_DEFAULT_REGION'), 63 | 'bucket' => env('AWS_BUCKET'), 64 | 'url' => env('AWS_URL'), 65 | 'endpoint' => env('AWS_ENDPOINT'), 66 | ], 67 | 68 | 's3-public' => [ 69 | 'driver' => 's3', 70 | 'key' => env('AWS_ACCESS_KEY_ID'), 71 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 72 | 'region' => env('AWS_DEFAULT_REGION'), 73 | 'bucket' => env('AWS_BUCKET_PUBLIC'), 74 | 'url' => env('AWS_URL'), 75 | 'endpoint' => env('AWS_ENDPOINT'), 76 | ], 77 | 78 | ], 79 | 80 | /* 81 | |-------------------------------------------------------------------------- 82 | | Symbolic Links 83 | |-------------------------------------------------------------------------- 84 | | 85 | | Here you may configure the symbolic links that will be created when the 86 | | `storage:link` Artisan command is executed. The array keys should be 87 | | the locations of the links and the values should be their targets. 88 | | 89 | */ 90 | 91 | 'links' => [ 92 | public_path('storage') => storage_path('app/public'), 93 | ], 94 | 95 | ]; 96 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Log Channels 25 | |-------------------------------------------------------------------------- 26 | | 27 | | Here you may configure the log channels for your application. Out of 28 | | the box, Laravel uses the Monolog PHP logging library. This gives 29 | | you a variety of powerful log handlers / formatters to utilize. 30 | | 31 | | Available Drivers: "single", "daily", "slack", "syslog", 32 | | "errorlog", "monolog", 33 | | "custom", "stack" 34 | | 35 | */ 36 | 37 | 'channels' => [ 38 | 'stack' => [ 39 | 'driver' => 'stack', 40 | 'channels' => ['single'], 41 | 'ignore_exceptions' => false, 42 | ], 43 | 44 | 'single' => [ 45 | 'driver' => 'single', 46 | 'path' => storage_path('logs/laravel.log'), 47 | 'level' => 'debug', 48 | ], 49 | 50 | 'daily' => [ 51 | 'driver' => 'daily', 52 | 'path' => storage_path('logs/laravel.log'), 53 | 'level' => 'debug', 54 | 'days' => 14, 55 | ], 56 | 57 | 'slack' => [ 58 | 'driver' => 'slack', 59 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 60 | 'username' => 'Laravel Log', 61 | 'emoji' => ':boom:', 62 | 'level' => 'critical', 63 | ], 64 | 65 | 'papertrail' => [ 66 | 'driver' => 'monolog', 67 | 'level' => 'debug', 68 | 'handler' => SyslogUdpHandler::class, 69 | 'handler_with' => [ 70 | 'host' => env('PAPERTRAIL_URL'), 71 | 'port' => env('PAPERTRAIL_PORT'), 72 | ], 73 | ], 74 | 75 | 'stderr' => [ 76 | 'driver' => 'monolog', 77 | 'handler' => StreamHandler::class, 78 | 'formatter' => env('LOG_STDERR_FORMATTER'), 79 | 'with' => [ 80 | 'stream' => 'php://stderr', 81 | ], 82 | ], 83 | 84 | 'syslog' => [ 85 | 'driver' => 'syslog', 86 | 'level' => 'debug', 87 | ], 88 | 89 | 'errorlog' => [ 90 | 'driver' => 'errorlog', 91 | 'level' => 'debug', 92 | ], 93 | 94 | 'null' => [ 95 | 'driver' => 'monolog', 96 | 'handler' => NullHandler::class, 97 | ], 98 | 99 | 'emergency' => [ 100 | 'path' => storage_path('logs/laravel.log'), 101 | ], 102 | ], 103 | 104 | ]; 105 | -------------------------------------------------------------------------------- /tests/Feature/Auth/LoginTest.php: -------------------------------------------------------------------------------- 1 | get(route('login')) 20 | ->assertSuccessful() 21 | ->assertSeeLivewire('auth.login'); 22 | } 23 | 24 | /** @test */ 25 | public function is_redirected_if_already_logged_in() 26 | { 27 | $user = factory(User::class)->create(); 28 | 29 | $this->be($user); 30 | 31 | $this->get(route('login')) 32 | ->assertRedirect(route('home')); 33 | } 34 | 35 | /** @test */ 36 | public function a_user_can_login() 37 | { 38 | $user = factory(User::class)->create(['password' => Hash::make('password')]); 39 | 40 | Livewire::test('auth.login') 41 | ->set('email', $user->email) 42 | ->set('password', 'password') 43 | ->call('authenticate'); 44 | 45 | $this->assertAuthenticatedAs($user); 46 | } 47 | 48 | /** @test */ 49 | public function is_redirected_to_the_home_page_after_login() 50 | { 51 | $user = factory(User::class)->create(['password' => Hash::make('password')]); 52 | 53 | Livewire::test('auth.login') 54 | ->set('email', $user->email) 55 | ->set('password', 'password') 56 | ->call('authenticate') 57 | ->assertRedirect(route('home')); 58 | } 59 | 60 | /** @test */ 61 | public function email_is_required() 62 | { 63 | $user = factory(User::class)->create(['password' => Hash::make('password')]); 64 | 65 | Livewire::test('auth.login') 66 | ->set('password', 'password') 67 | ->call('authenticate') 68 | ->assertHasErrors(['email' => 'required']); 69 | } 70 | 71 | /** @test */ 72 | public function email_must_be_valid_email() 73 | { 74 | $user = factory(User::class)->create(['password' => Hash::make('password')]); 75 | 76 | Livewire::test('auth.login') 77 | ->set('email', 'invalid-email') 78 | ->set('password', 'password') 79 | ->call('authenticate') 80 | ->assertHasErrors(['email' => 'email']); 81 | } 82 | 83 | /** @test */ 84 | public function password_is_required() 85 | { 86 | $user = factory(User::class)->create(['password' => Hash::make('password')]); 87 | 88 | Livewire::test('auth.login') 89 | ->set('email', $user->email) 90 | ->call('authenticate') 91 | ->assertHasErrors(['password' => 'required']); 92 | } 93 | 94 | /** @test */ 95 | public function bad_login_attempt_shows_message() 96 | { 97 | $user = factory(User::class)->create(); 98 | 99 | Livewire::test('auth.login') 100 | ->set('email', $user->email) 101 | ->set('password', 'bad-password') 102 | ->call('authenticate') 103 | ->assertHasErrors('email'); 104 | 105 | $this->assertFalse(Auth::check()); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Cache Stores 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may define all of the cache "stores" for your application as 29 | | well as their drivers. You may even define multiple stores for the 30 | | same cache driver to group types of items stored in your caches. 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'apc' => [ 37 | 'driver' => 'apc', 38 | ], 39 | 40 | 'array' => [ 41 | 'driver' => 'array', 42 | 'serialize' => false, 43 | ], 44 | 45 | 'database' => [ 46 | 'driver' => 'database', 47 | 'table' => 'cache', 48 | 'connection' => null, 49 | ], 50 | 51 | 'file' => [ 52 | 'driver' => 'file', 53 | 'path' => storage_path('framework/cache/data'), 54 | ], 55 | 56 | 'memcached' => [ 57 | 'driver' => 'memcached', 58 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 59 | 'sasl' => [ 60 | env('MEMCACHED_USERNAME'), 61 | env('MEMCACHED_PASSWORD'), 62 | ], 63 | 'options' => [ 64 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 65 | ], 66 | 'servers' => [ 67 | [ 68 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 69 | 'port' => env('MEMCACHED_PORT', 11211), 70 | 'weight' => 100, 71 | ], 72 | ], 73 | ], 74 | 75 | 'redis' => [ 76 | 'driver' => 'redis', 77 | 'connection' => 'cache', 78 | ], 79 | 80 | 'dynamodb' => [ 81 | 'driver' => 'dynamodb', 82 | 'key' => env('AWS_ACCESS_KEY_ID'), 83 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 84 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 85 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 86 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 87 | ], 88 | 89 | ], 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Cache Key Prefix 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When utilizing a RAM based store such as APC or Memcached, there might 97 | | be other applications utilizing the same cache. So, we'll specify a 98 | | value to get prefixed to all our keys so we can avoid collisions. 99 | | 100 | */ 101 | 102 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), 103 | 104 | ]; 105 | -------------------------------------------------------------------------------- /resources/views/livewire/auth/passwords/reset.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 | 6 | 7 |

8 | Reset password 9 |

10 |
11 | 12 |
13 |
14 |
15 | 16 | 17 |
18 | 21 | 22 |
23 | 24 |
25 | 26 | @error('email') 27 |

{{ $message }}

28 | @enderror 29 |
30 | 31 |
32 | 35 | 36 |
37 | 38 |
39 | 40 | @error('password') 41 |

{{ $message }}

42 | @enderror 43 |
44 | 45 |
46 | 49 | 50 |
51 | 52 |
53 |
54 | 55 |
56 | 57 | 60 | 61 |
62 |
63 |
64 |
65 |
66 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_MAILER', 'smtp'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Mailer Configurations 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure all of the mailers used by your application plus 24 | | their respective settings. Several examples have been configured for 25 | | you and you are free to add your own as your application requires. 26 | | 27 | | Laravel supports a variety of mail "transport" drivers to be used while 28 | | sending an e-mail. You will specify which one you are using for your 29 | | mailers below. You are free to add additional mailers as required. 30 | | 31 | | Supported: "smtp", "sendmail", "mailgun", "ses", 32 | | "postmark", "log", "array" 33 | | 34 | */ 35 | 36 | 'mailers' => [ 37 | 'smtp' => [ 38 | 'transport' => 'smtp', 39 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 40 | 'port' => env('MAIL_PORT', 587), 41 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 42 | 'username' => env('MAIL_USERNAME'), 43 | 'password' => env('MAIL_PASSWORD'), 44 | 'timeout' => null, 45 | 'auth_mode' => null, 46 | ], 47 | 48 | 'ses' => [ 49 | 'transport' => 'ses', 50 | ], 51 | 52 | 'mailgun' => [ 53 | 'transport' => 'mailgun', 54 | ], 55 | 56 | 'postmark' => [ 57 | 'transport' => 'postmark', 58 | ], 59 | 60 | 'sendmail' => [ 61 | 'transport' => 'sendmail', 62 | 'path' => '/usr/sbin/sendmail -bs', 63 | ], 64 | 65 | 'log' => [ 66 | 'transport' => 'log', 67 | 'channel' => env('MAIL_LOG_CHANNEL'), 68 | ], 69 | 70 | 'array' => [ 71 | 'transport' => 'array', 72 | ], 73 | ], 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Global "From" Address 78 | |-------------------------------------------------------------------------- 79 | | 80 | | You may wish for all e-mails sent by your application to be sent from 81 | | the same address. Here, you may specify a name and address that is 82 | | used globally for all e-mails that are sent by your application. 83 | | 84 | */ 85 | 86 | 'from' => [ 87 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 88 | 'name' => env('MAIL_FROM_NAME', 'Example'), 89 | ], 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Markdown Mail Settings 94 | |-------------------------------------------------------------------------- 95 | | 96 | | If you are using Markdown based email rendering, you may configure your 97 | | theme and component paths here, allowing you to customize the design 98 | | of the emails. Or, you may simply stick with the Laravel defaults! 99 | | 100 | */ 101 | 102 | 'markdown' => [ 103 | 'theme' => 'default', 104 | 105 | 'paths' => [ 106 | resource_path('views/vendor/mail'), 107 | ], 108 | ], 109 | 110 | ]; 111 | -------------------------------------------------------------------------------- /config/livewire.php: -------------------------------------------------------------------------------- 1 | 'App\\Http\\Livewire', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This value sets the path for Livewire component views. This effects 26 | | File manipulation helper commands like `artisan make:livewire` 27 | | 28 | */ 29 | 30 | 'view_path' => resource_path('views/livewire'), 31 | 32 | /* 33 | |-------------------------------------------------------------------------- 34 | | Livewire Assets URL 35 | |-------------------------------------------------------------------------- 36 | | 37 | | This value sets the path to Livewire JavaScript assets, for cases where 38 | | your app's domain root is not the correct path. By default, Livewire 39 | | will load its JavaScript assets from the app's "relative root". 40 | | 41 | | Examples: "/assets", "myurl.com/app" 42 | | 43 | */ 44 | 45 | 'asset_url' => null, 46 | 47 | /* 48 | |-------------------------------------------------------------------------- 49 | | Livewire Endpoint Middleware Group 50 | |-------------------------------------------------------------------------- 51 | | 52 | | This value sets the middleware group that will be applied to the main 53 | | Livewire "message" endpoint (the endpoint that gets hit everytime, 54 | | a Livewire component updates). It is set to "web" by default. 55 | | 56 | */ 57 | 58 | 'middleware_group' => 'web', 59 | 60 | /* 61 | |-------------------------------------------------------------------------- 62 | | Livewire Temporary File Uploads Endpoint Configuration 63 | |-------------------------------------------------------------------------- 64 | | 65 | | Livewire handles file uploads by storing uploads in a temporary directory 66 | | before the file is validated and stored permanently. All file uploads 67 | | are directed to a global endpoint for temporary storage. The config 68 | | items below are used for customizing the way the endpoint works. 69 | | 70 | */ 71 | 72 | 'temporary_file_upload' => [ 73 | 'disk' => 's3', // Example: 'local', 's3' Default: 'default' 74 | 'rules' => null, // Example: ['file', 'mimes:png,jpg'] Default: ['required', 'file', 'max:12288'] (12MB) 75 | 'directory' => null, // Example: 'tmp' Default 'livewire-tmp' 76 | 'middleware' => null, // Example: 'throttle:5,1' Default: 'throttle:60,1' 77 | ], 78 | 79 | /* 80 | |-------------------------------------------------------------------------- 81 | | Manifest File Path 82 | |-------------------------------------------------------------------------- 83 | | 84 | | This value sets the path to Livewire manifest file path. 85 | | The default should work for most cases (which is 86 | | "/bootstrap/cache/livewire-components.php)", but for specific 87 | | cases like when hosting on Laravel Vapor, it could be set to a different value. 88 | | 89 | | Example: For Laravel Vapor, it would be "/tmp/storage/bootstrap/cache/livewire-components.php" 90 | | 91 | */ 92 | 93 | 'manifest_path' => null, 94 | 95 | ]; 96 | -------------------------------------------------------------------------------- /tests/Feature/Auth/Passwords/ResetTest.php: -------------------------------------------------------------------------------- 1 | create(); 23 | 24 | $token = Str::random(16); 25 | 26 | DB::table('password_resets')->insert([ 27 | 'email' => $user->email, 28 | 'token' => Hash::make($token), 29 | 'created_at' => Carbon::now(), 30 | ]); 31 | 32 | $this->get(route('password.reset', [ 33 | 'email' => $user->email, 34 | 'token' => $token, 35 | ])) 36 | ->assertSuccessful() 37 | ->assertSeeLivewire('auth.passwords.reset'); 38 | } 39 | 40 | /** @test */ 41 | public function can_reset_password() 42 | { 43 | $user = factory(User::class)->create(); 44 | 45 | $token = Str::random(16); 46 | 47 | DB::table('password_resets')->insert([ 48 | 'email' => $user->email, 49 | 'token' => Hash::make($token), 50 | 'created_at' => Carbon::now(), 51 | ]); 52 | 53 | Livewire::test('auth.passwords.reset', [ 54 | 'token' => $token, 55 | ]) 56 | ->set('email', $user->email) 57 | ->set('password', 'new-password') 58 | ->set('passwordConfirmation', 'new-password') 59 | ->call('resetPassword'); 60 | 61 | $this->assertTrue(Auth::attempt([ 62 | 'email' => $user->email, 63 | 'password' => 'new-password', 64 | ])); 65 | } 66 | 67 | /** @test */ 68 | public function token_is_required() 69 | { 70 | Livewire::test('auth.passwords.reset', [ 71 | 'token' => null, 72 | ]) 73 | ->call('resetPassword') 74 | ->assertHasErrors(['token' => 'required']); 75 | } 76 | 77 | /** @test */ 78 | public function email_is_required() 79 | { 80 | Livewire::test('auth.passwords.reset', [ 81 | 'token' => Str::random(16), 82 | ]) 83 | ->set('email', null) 84 | ->call('resetPassword') 85 | ->assertHasErrors(['email' => 'required']); 86 | } 87 | 88 | /** @test */ 89 | public function email_is_valid_email() 90 | { 91 | Livewire::test('auth.passwords.reset', [ 92 | 'token' => Str::random(16), 93 | ]) 94 | ->set('email', 'email') 95 | ->call('resetPassword') 96 | ->assertHasErrors(['email' => 'email']); 97 | } 98 | 99 | /** @test */ 100 | function password_is_required() 101 | { 102 | Livewire::test('auth.passwords.reset', [ 103 | 'token' => Str::random(16), 104 | ]) 105 | ->set('password', '') 106 | ->call('resetPassword') 107 | ->assertHasErrors(['password' => 'required']); 108 | } 109 | 110 | /** @test */ 111 | function password_is_minimum_of_eight_characters() 112 | { 113 | Livewire::test('auth.passwords.reset', [ 114 | 'token' => Str::random(16), 115 | ]) 116 | ->set('password', 'secret') 117 | ->call('resetPassword') 118 | ->assertHasErrors(['password' => 'min']); 119 | } 120 | 121 | /** @test */ 122 | function password_matches_password_confirmation() 123 | { 124 | Livewire::test('auth.passwords.reset', [ 125 | 'token' => Str::random(16), 126 | ]) 127 | ->set('password', 'new-password') 128 | ->set('passwordConfirmation', 'not-new-password') 129 | ->call('resetPassword') 130 | ->assertHasErrors(['password' => 'same']); 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'token', 46 | 'provider' => 'users', 47 | 'hash' => false, 48 | ], 49 | ], 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | User Providers 54 | |-------------------------------------------------------------------------- 55 | | 56 | | All authentication drivers have a user provider. This defines how the 57 | | users are actually retrieved out of your database or other storage 58 | | mechanisms used by this application to persist your user's data. 59 | | 60 | | If you have multiple user tables or models you may configure multiple 61 | | sources which represent each model / table. These sources may then 62 | | be assigned to any extra authentication guards you have defined. 63 | | 64 | | Supported: "database", "eloquent" 65 | | 66 | */ 67 | 68 | 'providers' => [ 69 | 'users' => [ 70 | 'driver' => 'eloquent', 71 | 'model' => App\User::class, 72 | ], 73 | 74 | // 'users' => [ 75 | // 'driver' => 'database', 76 | // 'table' => 'users', 77 | // ], 78 | ], 79 | 80 | /* 81 | |-------------------------------------------------------------------------- 82 | | Resetting Passwords 83 | |-------------------------------------------------------------------------- 84 | | 85 | | You may specify multiple password reset configurations if you have more 86 | | than one user table or model in the application and you want to have 87 | | separate password reset settings based on the specific user types. 88 | | 89 | | The expire time is the number of minutes that the reset token should be 90 | | considered valid. This security feature keeps tokens short-lived so 91 | | they have less time to be guessed. You may change this as needed. 92 | | 93 | */ 94 | 95 | 'passwords' => [ 96 | 'users' => [ 97 | 'provider' => 'users', 98 | 'table' => 'password_resets', 99 | 'expire' => 60, 100 | 'throttle' => 60, 101 | ], 102 | ], 103 | 104 | /* 105 | |-------------------------------------------------------------------------- 106 | | Password Confirmation Timeout 107 | |-------------------------------------------------------------------------- 108 | | 109 | | Here you may define the amount of seconds before a password confirmation 110 | | times out and the user is prompted to re-enter their password via the 111 | | confirmation screen. By default, the timeout lasts for three hours. 112 | | 113 | */ 114 | 115 | 'password_timeout' => 10800, 116 | 117 | ]; 118 | -------------------------------------------------------------------------------- /tests/Feature/Auth/RegisterTest.php: -------------------------------------------------------------------------------- 1 | get(route('register')) 21 | ->assertSuccessful() 22 | ->assertSeeLivewire('auth.register'); 23 | } 24 | 25 | /** @test */ 26 | public function is_redirected_if_already_logged_in() 27 | { 28 | $user = factory(User::class)->create(); 29 | 30 | $this->be($user); 31 | 32 | $this->get(route('register')) 33 | ->assertRedirect(route('home')); 34 | } 35 | 36 | /** @test */ 37 | function a_user_can_register() 38 | { 39 | Livewire::test('auth.register') 40 | ->set('name', 'Tall Stack') 41 | ->set('email', 'tallstack@example.com') 42 | ->set('password', 'password') 43 | ->set('passwordConfirmation', 'password') 44 | ->call('register') 45 | ->assertRedirect(route('home')); 46 | 47 | $this->assertTrue(User::whereEmail('tallstack@example.com')->exists()); 48 | $this->assertEquals('tallstack@example.com', Auth::user()->email); 49 | } 50 | 51 | /** @test */ 52 | function name_is_required() 53 | { 54 | Livewire::test('auth.register') 55 | ->set('name', '') 56 | ->call('register') 57 | ->assertHasErrors(['email' => 'required']); 58 | } 59 | 60 | /** @test */ 61 | function email_is_required() 62 | { 63 | Livewire::test('auth.register') 64 | ->set('email', '') 65 | ->call('register') 66 | ->assertHasErrors(['email' => 'required']); 67 | } 68 | 69 | /** @test */ 70 | function email_is_valid_email() 71 | { 72 | Livewire::test('auth.register') 73 | ->set('email', 'tallstack') 74 | ->call('register') 75 | ->assertHasErrors(['email' => 'email']); 76 | } 77 | 78 | /** @test */ 79 | function email_hasnt_been_taken_already() 80 | { 81 | factory(User::class)->create(['email' => 'tallstack@example.com']); 82 | 83 | Livewire::test('auth.register') 84 | ->set('email', 'tallstack@example.com') 85 | ->call('register') 86 | ->assertHasErrors(['email' => 'unique']); 87 | } 88 | 89 | /** @test */ 90 | function see_email_hasnt_already_been_taken_validation_message_as_user_types() 91 | { 92 | factory(User::class)->create(['email' => 'tallstack@example.com']); 93 | 94 | Livewire::test('auth.register') 95 | ->set('email', 'smallstack@gmail.com') 96 | ->assertHasNoErrors() 97 | ->set('email', 'tallstack@example.com') 98 | ->call('register') 99 | ->assertHasErrors(['email' => 'unique']); 100 | } 101 | 102 | /** @test */ 103 | function password_is_required() 104 | { 105 | Livewire::test('auth.register') 106 | ->set('password', '') 107 | ->set('passwordConfirmation', 'password') 108 | ->call('register') 109 | ->assertHasErrors(['password' => 'required']); 110 | } 111 | 112 | /** @test */ 113 | function password_is_minimum_of_eight_characters() 114 | { 115 | Livewire::test('auth.register') 116 | ->set('password', 'secret') 117 | ->set('passwordConfirmation', 'secret') 118 | ->call('register') 119 | ->assertHasErrors(['password' => 'min']); 120 | } 121 | 122 | /** @test */ 123 | function password_matches_password_confirmation() 124 | { 125 | Livewire::test('auth.register') 126 | ->set('email', 'tallstack@example.com') 127 | ->set('password', 'password') 128 | ->set('passwordConfirmation', 'not-password') 129 | ->call('register') 130 | ->assertHasErrors(['password' => 'same']); 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /resources/views/livewire/auth/login.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 | 6 | 7 |

8 | Sign in to your account 9 |

10 |

11 | Or 12 | 13 | create a new account 14 | 15 |

16 |
17 | 18 |
19 |
20 |
21 |
22 | 25 | 26 |
27 | 28 |
29 | 30 | @error('email') 31 |

{{ $message }}

32 | @enderror 33 |
34 | 35 |
36 | 39 | 40 |
41 | 42 |
43 | 44 | @error('password') 45 |

{{ $message }}

46 | @enderror 47 |
48 | 49 |
50 |
51 | 52 | 55 |
56 | 57 | 62 |
63 | 64 |
65 | 66 | 69 | 70 |
71 |
72 |
73 |
74 |
75 | --------------------------------------------------------------------------------