├── .babelrc ├── .editorconfig ├── .env.dusk ├── .env.example ├── .eslintrc.js ├── .gitattributes ├── .github └── workflows │ └── tests.yml ├── .gitignore ├── .styleci.yml ├── LICENSE ├── app ├── Console │ └── Kernel.php ├── Exceptions │ ├── EmailTakenException.php │ ├── Handler.php │ └── VerifyEmailException.php ├── Http │ ├── Controllers │ │ ├── Auth │ │ │ ├── ForgotPasswordController.php │ │ │ ├── LoginController.php │ │ │ ├── OAuthController.php │ │ │ ├── RegisterController.php │ │ │ ├── ResetPasswordController.php │ │ │ ├── UserController.php │ │ │ └── VerificationController.php │ │ ├── Controller.php │ │ ├── Settings │ │ │ ├── PasswordController.php │ │ │ └── ProfileController.php │ │ └── SpaController.php │ ├── Kernel.php │ └── Middleware │ │ ├── Authenticate.php │ │ ├── EncryptCookies.php │ │ ├── PreventRequestsDuringMaintenance.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── SetLocale.php │ │ ├── TrimStrings.php │ │ ├── TrustHosts.php │ │ ├── TrustProxies.php │ │ └── VerifyCsrfToken.php ├── Models │ ├── OAuthProvider.php │ └── User.php ├── Notifications │ ├── ResetPassword.php │ └── VerifyEmail.php └── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ └── RouteServiceProvider.php ├── artisan ├── bootstrap ├── app.php └── cache │ └── .gitignore ├── composer.json ├── composer.lock ├── config ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── cors.php ├── database.php ├── filesystems.php ├── hashing.php ├── logging.php ├── mail.php ├── queue.php ├── services.php ├── session.php └── view.php ├── database ├── .gitignore ├── factories │ └── UserFactory.php ├── migrations │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2017_12_07_122845_create_oauth_providers_table.php │ └── 2019_08_19_000000_create_failed_jobs_table.php └── seeders │ └── DatabaseSeeder.php ├── package-lock.json ├── package.json ├── phpunit.xml ├── public ├── .htaccess ├── favicon.ico ├── index.php ├── robots.txt └── web.config ├── resources ├── js │ ├── app.js │ ├── components │ │ ├── App.vue │ │ ├── Button.vue │ │ ├── Card.vue │ │ ├── Checkbox.vue │ │ ├── Child.vue │ │ ├── Loading.vue │ │ ├── LocaleDropdown.vue │ │ ├── LoginWithGithub.vue │ │ ├── Navbar.vue │ │ └── index.js │ ├── lang │ │ ├── en.json │ │ ├── es.json │ │ ├── fr.json │ │ ├── pt-BR.json │ │ └── zh-CN.json │ ├── layouts │ │ ├── basic.vue │ │ ├── default.vue │ │ └── error.vue │ ├── middleware │ │ ├── admin.js │ │ ├── auth.js │ │ ├── check-auth.js │ │ ├── guest.js │ │ ├── locale.js │ │ └── role.js │ ├── pages │ │ ├── auth │ │ │ ├── login.vue │ │ │ ├── password │ │ │ │ ├── email.vue │ │ │ │ └── reset.vue │ │ │ ├── register.vue │ │ │ └── verification │ │ │ │ ├── resend.vue │ │ │ │ └── verify.vue │ │ ├── errors │ │ │ └── 404.vue │ │ ├── home.vue │ │ ├── settings │ │ │ ├── index.vue │ │ │ ├── password.vue │ │ │ └── profile.vue │ │ └── welcome.vue │ ├── plugins │ │ ├── axios.js │ │ ├── fontawesome.js │ │ ├── i18n.js │ │ └── index.js │ ├── router │ │ ├── index.js │ │ └── routes.js │ └── store │ │ ├── index.js │ │ ├── modules │ │ ├── auth.js │ │ └── lang.js │ │ └── mutation-types.js ├── lang │ ├── en │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ ├── validation.php │ │ └── verification.php │ ├── es │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php │ ├── pt-BR │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php │ └── zh-CN │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php ├── sass │ ├── _variables.scss │ ├── app.scss │ ├── components │ │ └── _server-error.scss │ └── elements │ │ ├── _buttons.scss │ │ ├── _card.scss │ │ ├── _navbar.scss │ │ └── _transitions.scss └── views │ ├── errors │ └── layout.blade.php │ ├── oauth │ ├── callback.blade.php │ └── emailTaken.blade.php │ └── spa.blade.php ├── routes ├── api.php ├── channels.php ├── console.php ├── spa.php └── web.php ├── server.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ ├── .gitignore │ │ └── data │ │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ ├── testing │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore ├── tests ├── Browser │ ├── ExampleTest.php │ ├── LoginTest.php │ ├── Pages │ │ ├── Home.php │ │ ├── HomePage.php │ │ ├── Login.php │ │ ├── Page.php │ │ └── Register.php │ ├── RegisterTest.php │ ├── WelcomeTest.php │ ├── console │ │ └── .gitignore │ ├── screenshots │ │ └── .gitignore │ └── source │ │ └── .gitignore ├── CreatesApplication.php ├── DuskTestCase.php ├── Feature │ ├── LocaleTest.php │ ├── LoginTest.php │ ├── OAuthTest.php │ ├── RegisterTest.php │ ├── SettingsTest.php │ └── VerificationTest.php ├── TestCase.php └── Unit │ └── ExampleTest.php └── webpack.mix.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/preset-env" 4 | ], 5 | "plugins": [ 6 | "@babel/plugin-syntax-dynamic-import" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{vue,js,json,html,scss,blade.php,yml}] 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /.env.dusk: -------------------------------------------------------------------------------- 1 | APP_NAME="Laravel Vue Spa" 2 | APP_ENV=testing 3 | APP_KEY=base64:ZDLf88XPAUgLJv7l6c8IxGpKXxZGobomG994vKY03qk= 4 | APP_DEBUG=true 5 | APP_LOG_LEVEL=debug 6 | APP_URL=http://127.0.0.1:8000 7 | 8 | LOG_CHANNEL=stack 9 | LOG_LEVEL=debug 10 | 11 | DB_CONNECTION=dusk 12 | 13 | BROADCAST_DRIVER=log 14 | CACHE_DRIVER=file 15 | QUEUE_CONNECTION=sync 16 | SESSION_DRIVER=file 17 | SESSION_LIFETIME=120 18 | 19 | REDIS_HOST=127.0.0.1 20 | REDIS_PASSWORD=null 21 | REDIS_PORT=6379 22 | 23 | MAIL_MAILER=smtp 24 | MAIL_HOST=smtp.mailtrap.io 25 | MAIL_PORT=2525 26 | MAIL_USERNAME=null 27 | MAIL_PASSWORD=null 28 | MAIL_ENCRYPTION=null 29 | MAIL_FROM_ADDRESS=null 30 | MAIL_FROM_NAME="${APP_NAME}" 31 | 32 | AWS_ACCESS_KEY_ID= 33 | AWS_SECRET_ACCESS_KEY= 34 | AWS_DEFAULT_REGION=us-east-1 35 | AWS_BUCKET= 36 | 37 | PUSHER_APP_ID= 38 | PUSHER_APP_KEY= 39 | PUSHER_APP_SECRET= 40 | PUSHER_APP_CLUSTER=mt1 41 | 42 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 43 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 44 | 45 | JWT_TTL=1440 46 | JWT_SECRET=eJkecpCqbVBJn7Wvnt5GXTjIRoYh1OjwvDQywVobjwKbmGmwt4UUqPo3y6IlnqAG 47 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME="Laravel Vue Spa" 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_LOG_LEVEL=debug 6 | APP_URL=http://localhost 7 | 8 | LOG_CHANNEL=stack 9 | LOG_LEVEL=debug 10 | 11 | DB_CONNECTION=mysql 12 | DB_HOST=127.0.0.1 13 | DB_PORT=3306 14 | DB_DATABASE=laravel 15 | DB_USERNAME=root 16 | DB_PASSWORD= 17 | 18 | BROADCAST_DRIVER=log 19 | CACHE_DRIVER=file 20 | QUEUE_CONNECTION=sync 21 | SESSION_DRIVER=file 22 | SESSION_LIFETIME=120 23 | 24 | REDIS_HOST=127.0.0.1 25 | REDIS_PASSWORD=null 26 | REDIS_PORT=6379 27 | 28 | MAIL_MAILER=smtp 29 | MAIL_HOST=smtp.mailtrap.io 30 | MAIL_PORT=2525 31 | MAIL_USERNAME=null 32 | MAIL_PASSWORD=null 33 | MAIL_ENCRYPTION=null 34 | MAIL_FROM_ADDRESS=null 35 | MAIL_FROM_NAME="${APP_NAME}" 36 | 37 | AWS_ACCESS_KEY_ID= 38 | AWS_SECRET_ACCESS_KEY= 39 | AWS_DEFAULT_REGION=us-east-1 40 | AWS_BUCKET= 41 | 42 | PUSHER_APP_ID= 43 | PUSHER_APP_KEY= 44 | PUSHER_APP_SECRET= 45 | PUSHER_APP_CLUSTER=mt1 46 | 47 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 48 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 49 | 50 | JWT_TTL=1440 51 | JWT_SECRET= 52 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: 'vue-eslint-parser', 4 | parserOptions: { 5 | parser: '@babel/eslint-parser', 6 | ecmaVersion: 2018, 7 | sourceType: 'module' 8 | }, 9 | extends: [ 10 | 'plugin:vue/recommended', 11 | 'standard' 12 | ], 13 | rules: { 14 | 'vue/max-attributes-per-line': 'off' 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | README.md export-ignore 7 | .travis.yml export-ignore 8 | .env.dusk.local export-ignore 9 | .env.dusk.testing export-ignore 10 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: tests 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | jobs: 8 | tests: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | strategy: 13 | fail-fast: true 14 | matrix: 15 | php: [7.3, 7.4, 8.0] 16 | 17 | name: PHP ${{ matrix.php }} 18 | 19 | steps: 20 | - name: Checkout code 21 | uses: actions/checkout@v2 22 | 23 | - name: Get Composer cache directory 24 | id: composer-cache 25 | run: | 26 | echo "::set-output name=dir::$(composer config cache-files-dir)" 27 | 28 | - uses: actions/cache@v2 29 | with: 30 | path: ${{ steps.composer-cache.outputs.dir }} 31 | key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} 32 | restore-keys: | 33 | ${{ runner.os }}-composer- 34 | 35 | - uses: actions/cache@v2 36 | with: 37 | path: ~/.npm 38 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} 39 | restore-keys: | 40 | ${{ runner.os }}-node- 41 | 42 | - name: Setup PHP 43 | uses: shivammathur/setup-php@v2 44 | with: 45 | php-version: ${{ matrix.php }} 46 | extensions: dom, curl, mbstring, pdo, sqlite, pdo_sqlite 47 | tools: composer:v2 48 | coverage: none 49 | 50 | - name: Prepare the environment 51 | run: cp .env.example .env 52 | 53 | - name: Install composer dependencies 54 | run: composer install --prefer-dist --no-interaction --no-progress --ignore-platform-reqs --optimize-autoloader 55 | 56 | - name: Directory permissions 57 | run: chmod -R 777 storage bootstrap/cache 58 | 59 | - name: Run tests (Unit and Feature) 60 | run: vendor/bin/phpunit 61 | 62 | - name: Install npm dependencies 63 | run: npm install --no-audit --no-progress --silent 64 | 65 | - name: Build client 66 | run: npm run build 67 | 68 | - name: Upgrade Chrome driver 69 | run: php artisan dusk:chrome-driver `/opt/google/chrome/chrome --version | cut -d " " -f3 | cut -d "." -f1` 70 | 71 | - name: Start Chrome driver 72 | run: ./vendor/laravel/dusk/bin/chromedriver-linux & 73 | 74 | - name: Create database 75 | run: touch database/dusk.sqlite 76 | 77 | - name: Run Laravel server 78 | run: php artisan serve & 79 | 80 | - name: Run Dusk tests 81 | env: 82 | APP_URL: "http://127.0.0.1:8000" 83 | run: php artisan dusk 84 | 85 | - name: Upload screenshots 86 | if: failure() 87 | uses: actions/upload-artifact@v2 88 | with: 89 | name: screenshots 90 | path: tests/Browser/screenshots 91 | 92 | - name: Upload console logs 93 | if: failure() 94 | uses: actions/upload-artifact@v2 95 | with: 96 | name: console 97 | path: tests/Browser/console 98 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /storage/*.key 5 | /vendor 6 | .env 7 | .env.backup 8 | .env.dusk.local 9 | .phpunit.result.cache 10 | Homestead.json 11 | Homestead.yaml 12 | npm-debug.log 13 | yarn-error.log 14 | phpunit.dusk.xml 15 | /public/dist 16 | /public/build 17 | /public/mix-manifest.json 18 | -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | php: 2 | preset: laravel 3 | disabled: 4 | - no_unused_imports 5 | finder: 6 | not-name: 7 | - index.php 8 | - server.php 9 | js: 10 | finder: 11 | not-name: 12 | - webpack.mix.js 13 | css: true 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Cretu Eusebiu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /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/Exceptions/EmailTakenException.php: -------------------------------------------------------------------------------- 1 | view('oauth.emailTaken', [], 400); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | expectsJson() 40 | ? response()->json(['message' => $exception->getMessage()], 401) 41 | : redirect()->guest(url('/login')); 42 | } 43 | 44 | /** 45 | * Prepare a JSON response for the given exception. 46 | * 47 | * @param \Illuminate\Http\Request $request 48 | * @param \Throwable $e 49 | * @return \Symfony\Component\HttpFoundation\Response 50 | */ 51 | protected function prepareJsonResponse($request, Throwable $e) 52 | { 53 | $response = parent::prepareJsonResponse($request, $e); 54 | 55 | if ($response->getStatusCode() === 500 && config('app.debug')) { 56 | return $this->prepareResponse($request, $e); 57 | } 58 | 59 | return $response; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/Exceptions/VerifyEmailException.php: -------------------------------------------------------------------------------- 1 | [__('You must :linkOpen verify :linkClose your email first.', [ 17 | 'linkOpen' => '', 18 | 'linkClose' => '', 19 | ])], 20 | ]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 19 | } 20 | 21 | /** 22 | * Get the response for a successful password reset link. 23 | */ 24 | protected function sendResetLinkResponse(Request $request, string $response) 25 | { 26 | return response()->json(['status' => trans($response)]); 27 | } 28 | 29 | /** 30 | * Get the response for a failed password reset link. 31 | */ 32 | protected function sendResetLinkFailedResponse(Request $request, string $response) 33 | { 34 | return response()->json(['email' => trans($response)], 400); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/LoginController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 22 | } 23 | 24 | /** 25 | * Attempt to log the user into the application. 26 | */ 27 | protected function attemptLogin(Request $request): bool 28 | { 29 | $token = $this->guard()->attempt($this->credentials($request)); 30 | 31 | if (! $token) { 32 | return false; 33 | } 34 | 35 | $user = $this->guard()->user(); 36 | if ($user instanceof MustVerifyEmail && ! $user->hasVerifiedEmail()) { 37 | return false; 38 | } 39 | 40 | $this->guard()->setToken($token); 41 | 42 | return true; 43 | } 44 | 45 | /** 46 | * Send the response after the user was authenticated. 47 | */ 48 | protected function sendLoginResponse(Request $request) 49 | { 50 | $this->clearLoginAttempts($request); 51 | 52 | $token = (string) $this->guard()->getToken(); 53 | $expiration = $this->guard()->getPayload()->get('exp'); 54 | 55 | return response()->json([ 56 | 'token' => $token, 57 | 'token_type' => 'bearer', 58 | 'expires_in' => $expiration - time(), 59 | ]); 60 | } 61 | 62 | /** 63 | * Get the failed login response instance. 64 | */ 65 | protected function sendFailedLoginResponse(Request $request) 66 | { 67 | $user = $this->guard()->user(); 68 | 69 | if ($user instanceof MustVerifyEmail && ! $user->hasVerifiedEmail()) { 70 | throw VerifyEmailException::forUser($user); 71 | } 72 | 73 | throw ValidationException::withMessages([ 74 | $this->username() => [trans('auth.failed')], 75 | ]); 76 | } 77 | 78 | /** 79 | * Log the user out of the application. 80 | */ 81 | public function logout(Request $request) 82 | { 83 | $this->guard()->logout(); 84 | 85 | return response()->json(null, 204); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/OAuthController.php: -------------------------------------------------------------------------------- 1 | route('oauth.callback', 'github'), 24 | ]); 25 | } 26 | 27 | /** 28 | * Redirect the user to the provider authentication page. 29 | */ 30 | public function redirect(string $provider) 31 | { 32 | return response()->json([ 33 | 'url' => Socialite::driver($provider)->stateless()->redirect()->getTargetUrl(), 34 | ]); 35 | } 36 | 37 | /** 38 | * Obtain the user information from the provider. 39 | */ 40 | public function handleCallback(string $provider) 41 | { 42 | $user = Socialite::driver($provider)->stateless()->user(); 43 | $user = $this->findOrCreateUser($provider, $user); 44 | 45 | $this->guard()->setToken( 46 | $token = $this->guard()->login($user) 47 | ); 48 | 49 | return view('oauth/callback', [ 50 | 'token' => $token, 51 | 'token_type' => 'bearer', 52 | 'expires_in' => $this->guard()->getPayload()->get('exp') - time(), 53 | ]); 54 | } 55 | 56 | /** 57 | * Find or create a user. 58 | */ 59 | protected function findOrCreateUser(string $provider, SocialiteUser $user): User 60 | { 61 | $oauthProvider = OAuthProvider::where('provider', $provider) 62 | ->where('provider_user_id', $user->getId()) 63 | ->first(); 64 | 65 | if ($oauthProvider) { 66 | $oauthProvider->update([ 67 | 'access_token' => $user->token, 68 | 'refresh_token' => $user->refreshToken, 69 | ]); 70 | 71 | return $oauthProvider->user; 72 | } 73 | 74 | if (User::where('email', $user->getEmail())->exists()) { 75 | throw new EmailTakenException; 76 | } 77 | 78 | return $this->createUser($provider, $user); 79 | } 80 | 81 | /** 82 | * Create a new user. 83 | */ 84 | protected function createUser(string $provider, SocialiteUser $sUser): User 85 | { 86 | $user = User::create([ 87 | 'name' => $sUser->getName(), 88 | 'email' => $sUser->getEmail(), 89 | 'email_verified_at' => now(), 90 | ]); 91 | 92 | $user->oauthProviders()->create([ 93 | 'provider' => $provider, 94 | 'provider_user_id' => $sUser->getId(), 95 | 'access_token' => $sUser->token, 96 | 'refresh_token' => $sUser->refreshToken, 97 | ]); 98 | 99 | return $user; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisterController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 22 | } 23 | 24 | /** 25 | * The user has been registered. 26 | */ 27 | protected function registered(Request $request, User $user) 28 | { 29 | if ($user instanceof MustVerifyEmail) { 30 | return response()->json(['status' => trans('verification.sent')]); 31 | } 32 | 33 | return response()->json($user); 34 | } 35 | 36 | /** 37 | * Get a validator for an incoming registration request. 38 | */ 39 | protected function validator(array $data) 40 | { 41 | return Validator::make($data, [ 42 | 'name' => 'required|max:255', 43 | 'email' => 'required|email:filter|max:255|unique:users', 44 | 'password' => 'required|min:6|confirmed', 45 | ]); 46 | } 47 | 48 | /** 49 | * Create a new user instance after a valid registration. 50 | */ 51 | protected function create(array $data): User 52 | { 53 | return User::create([ 54 | 'name' => $data['name'], 55 | 'email' => $data['email'], 56 | 'password' => bcrypt($data['password']), 57 | ]); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 19 | } 20 | 21 | /** 22 | * Get the response for a successful password reset. 23 | */ 24 | protected function sendResetResponse(Request $request, string $response) 25 | { 26 | return ['status' => trans($response)]; 27 | } 28 | 29 | /** 30 | * Get the response for a failed password reset. 31 | */ 32 | protected function sendResetFailedResponse(Request $request, string $response) 33 | { 34 | return response()->json(['email' => trans($response)], 400); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/UserController.php: -------------------------------------------------------------------------------- 1 | json($request->user()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/VerificationController.php: -------------------------------------------------------------------------------- 1 | middleware('throttle:6,1')->only('verify', 'resend'); 20 | } 21 | 22 | /** 23 | * Mark the user's email address as verified. 24 | */ 25 | public function verify(Request $request, User $user) 26 | { 27 | if (! URL::hasValidSignature($request)) { 28 | return response()->json([ 29 | 'status' => trans('verification.invalid'), 30 | ], 400); 31 | } 32 | 33 | if ($user->hasVerifiedEmail()) { 34 | return response()->json([ 35 | 'status' => trans('verification.already_verified'), 36 | ], 400); 37 | } 38 | 39 | $user->markEmailAsVerified(); 40 | 41 | event(new Verified($user)); 42 | 43 | return response()->json([ 44 | 'status' => trans('verification.verified'), 45 | ]); 46 | } 47 | 48 | /** 49 | * Resend the email verification notification. 50 | */ 51 | public function resend(Request $request) 52 | { 53 | $this->validate($request, ['email' => 'required|email']); 54 | 55 | $user = User::where('email', $request->email)->first(); 56 | 57 | if (is_null($user)) { 58 | throw ValidationException::withMessages([ 59 | 'email' => [trans('verification.user')], 60 | ]); 61 | } 62 | 63 | if ($user->hasVerifiedEmail()) { 64 | throw ValidationException::withMessages([ 65 | 'email' => [trans('verification.already_verified')], 66 | ]); 67 | } 68 | 69 | $user->sendEmailVerificationNotification(); 70 | 71 | return response()->json(['status' => trans('verification.sent')]); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | validate($request, [ 16 | 'password' => 'required|confirmed|min:6', 17 | ]); 18 | 19 | $request->user()->update([ 20 | 'password' => bcrypt($request->password), 21 | ]); 22 | 23 | return response()->json(null, 204); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/Http/Controllers/Settings/ProfileController.php: -------------------------------------------------------------------------------- 1 | user(); 16 | 17 | $this->validate($request, [ 18 | 'name' => 'required', 19 | 'email' => 'required|email|unique:users,email,'.$user->id, 20 | ]); 21 | 22 | $user->update($request->only('name', 'email')); 23 | 24 | return response()->json($user); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Controllers/SpaController.php: -------------------------------------------------------------------------------- 1 | [ 34 | \App\Http\Middleware\EncryptCookies::class, 35 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 36 | \Illuminate\Session\Middleware\StartSession::class, 37 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 38 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 39 | \App\Http\Middleware\VerifyCsrfToken::class, 40 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 41 | ], 42 | 43 | 'spa' => [ 44 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 45 | ], 46 | 47 | 'api' => [ 48 | 'throttle:60,1', 49 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 50 | ], 51 | ]; 52 | 53 | /** 54 | * The application's route middleware. 55 | * 56 | * These middleware may be assigned to groups or used individually. 57 | * 58 | * @var array 59 | */ 60 | protected $routeMiddleware = [ 61 | 'auth' => \App\Http\Middleware\Authenticate::class, 62 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 63 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 64 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 65 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 66 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 67 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 68 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 69 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 70 | ]; 71 | } 72 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return redirect('/login'); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | check()) { 26 | if ($request->expectsJson()) { 27 | return response()->json(['error' => 'Already authenticated.'], 400); 28 | } else { 29 | return redirect(RouteServiceProvider::HOME); 30 | } 31 | } 32 | } 33 | 34 | return $next($request); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Http/Middleware/SetLocale.php: -------------------------------------------------------------------------------- 1 | parseLocale($request)) { 19 | app()->setLocale($locale); 20 | } 21 | 22 | return $next($request); 23 | } 24 | 25 | /** 26 | * @param \Illuminate\Http\Request $request 27 | * @return string|null 28 | */ 29 | protected function parseLocale($request) 30 | { 31 | $locales = config('app.locales'); 32 | 33 | $locale = $request->server('HTTP_ACCEPT_LANGUAGE'); 34 | $locale = substr($locale, 0, strpos($locale, ',') ?: strlen($locale)); 35 | 36 | if (array_key_exists($locale, $locales)) { 37 | return $locale; 38 | } 39 | 40 | $locale = substr($locale, 0, 2); 41 | if (array_key_exists($locale, $locales)) { 42 | return $locale; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | 'datetime', 46 | ]; 47 | 48 | /** 49 | * The accessors to append to the model's array form. 50 | * 51 | * @var array 52 | */ 53 | protected $appends = [ 54 | 'photo_url', 55 | ]; 56 | 57 | /** 58 | * Get the profile photo URL attribute. 59 | * 60 | * @return string 61 | */ 62 | public function getPhotoUrlAttribute() 63 | { 64 | return vsprintf('https://www.gravatar.com/avatar/%s.jpg?s=200&d=%s', [ 65 | md5(strtolower($this->email)), 66 | $this->name ? urlencode("https://ui-avatars.com/api/$this->name") : 'mp', 67 | ]); 68 | } 69 | 70 | /** 71 | * Get the oauth providers. 72 | * 73 | * @return \Illuminate\Database\Eloquent\Relations\HasMany 74 | */ 75 | public function oauthProviders() 76 | { 77 | return $this->hasMany(OAuthProvider::class); 78 | } 79 | 80 | /** 81 | * Send the password reset notification. 82 | * 83 | * @param string $token 84 | * @return void 85 | */ 86 | public function sendPasswordResetNotification($token) 87 | { 88 | $this->notify(new ResetPassword($token)); 89 | } 90 | 91 | /** 92 | * Send the email verification notification. 93 | * 94 | * @return void 95 | */ 96 | public function sendEmailVerificationNotification() 97 | { 98 | $this->notify(new VerifyEmail); 99 | } 100 | 101 | /** 102 | * @return int 103 | */ 104 | public function getJWTIdentifier() 105 | { 106 | return $this->getKey(); 107 | } 108 | 109 | /** 110 | * @return array 111 | */ 112 | public function getJWTCustomClaims() 113 | { 114 | return []; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /app/Notifications/ResetPassword.php: -------------------------------------------------------------------------------- 1 | line('You are receiving this email because we received a password reset request for your account.') 20 | ->action('Reset Password', url(config('app.url').'/password/reset/'.$this->token).'?email='.urlencode($notifiable->email)) 21 | ->line('If you did not request a password reset, no further action is required.'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/Notifications/VerifyEmail.php: -------------------------------------------------------------------------------- 1 | addMinutes(60), ['user' => $notifiable->id] 21 | ); 22 | 23 | return str_replace('/api', '', $url); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->runningUnitTests()) { 19 | Schema::defaultStringLength(191); 20 | } 21 | } 22 | 23 | /** 24 | * Register any application services. 25 | * 26 | * @return void 27 | */ 28 | public function register() 29 | { 30 | if ($this->app->environment('local', 'testing') && class_exists(DuskServiceProvider::class)) { 31 | $this->app->register(DuskServiceProvider::class); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 16 | ]; 17 | 18 | /** 19 | * Register any authentication / authorization services. 20 | * 21 | * @return void 22 | */ 23 | public function boot() 24 | { 25 | $this->registerPolicies(); 26 | 27 | // 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | * 26 | * @return void 27 | */ 28 | public function boot() 29 | { 30 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | configureRateLimiting(); 39 | 40 | $this->routes(function () { 41 | Route::prefix('api') 42 | ->middleware('api') 43 | ->namespace($this->namespace) 44 | ->group(base_path('routes/api.php')); 45 | 46 | Route::middleware('web') 47 | ->namespace($this->namespace) 48 | ->group(base_path('routes/web.php')); 49 | 50 | Route::middleware('spa') 51 | ->namespace($this->namespace) 52 | ->group(base_path('routes/spa.php')); 53 | }); 54 | } 55 | 56 | /** 57 | * Configure the rate limiters for the application. 58 | * 59 | * @return void 60 | */ 61 | protected function configureRateLimiting() 62 | { 63 | RateLimiter::for('api', function (Request $request) { 64 | return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); 65 | }); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cretueusebiu/laravel-vue-spa", 3 | "description": "A Laravel-Vue SPA starter project template.", 4 | "keywords": ["spa", "laravel", "vue"], 5 | "license": "MIT", 6 | "type": "project", 7 | "require": { 8 | "php": "^7.3|^8.0", 9 | "fideloper/proxy": "^4.4", 10 | "fruitcake/laravel-cors": "^2.0", 11 | "guzzlehttp/guzzle": "^7.0.1", 12 | "laravel/framework": "^8.54", 13 | "laravel/socialite": "^5.2", 14 | "laravel/tinker": "^2.6", 15 | "laravel/ui": "^3.3", 16 | "tymon/jwt-auth": "dev-develop" 17 | }, 18 | "require-dev": { 19 | "doctrine/dbal": "^2.13", 20 | "facade/ignition": "^2.5", 21 | "fakerphp/faker": "^1.9.1", 22 | "laravel/dusk": "^6.17", 23 | "mockery/mockery": "^1.4.2", 24 | "nunomaduro/collision": "^5.0", 25 | "phpunit/phpunit": "^9.3.3" 26 | }, 27 | "autoload": { 28 | "psr-4": { 29 | "App\\": "app/", 30 | "Database\\Factories\\": "database/factories/", 31 | "Database\\Seeders\\": "database/seeders/" 32 | } 33 | }, 34 | "autoload-dev": { 35 | "psr-4": { 36 | "Tests\\": "tests/" 37 | } 38 | }, 39 | "scripts": { 40 | "post-autoload-dump": [ 41 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 42 | "@php artisan package:discover --ansi" 43 | ], 44 | "post-root-package-install": [ 45 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 46 | ], 47 | "post-create-project-cmd": [ 48 | "@php artisan key:generate --ansi", 49 | "@php artisan jwt:secret --force --ansi" 50 | ] 51 | }, 52 | "extra": { 53 | "laravel": { 54 | "dont-discover": [ 55 | "laravel/dusk" 56 | ] 57 | } 58 | }, 59 | "config": { 60 | "optimize-autoloader": true, 61 | "preferred-install": "dist", 62 | "sort-packages": true 63 | }, 64 | "minimum-stability": "dev", 65 | "prefer-stable": true 66 | } 67 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'api', 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' => 'jwt', 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\Models\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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Database Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here are each of the database connections setup for your application. 26 | | Of course, examples of configuring each database platform that is 27 | | supported by Laravel is shown below to make development simple. 28 | | 29 | | 30 | | All database work in Laravel is done through the PHP PDO facilities 31 | | so make sure you have the driver for your particular database of 32 | | choice installed on your machine before you begin development. 33 | | 34 | */ 35 | 36 | 'connections' => [ 37 | 38 | 'sqlite' => [ 39 | 'driver' => 'sqlite', 40 | 'url' => env('DATABASE_URL'), 41 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 42 | 'prefix' => '', 43 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 44 | ], 45 | 46 | 'mysql' => [ 47 | 'driver' => 'mysql', 48 | 'url' => env('DATABASE_URL'), 49 | 'host' => env('DB_HOST', '127.0.0.1'), 50 | 'port' => env('DB_PORT', '3306'), 51 | 'database' => env('DB_DATABASE', 'forge'), 52 | 'username' => env('DB_USERNAME', 'forge'), 53 | 'password' => env('DB_PASSWORD', ''), 54 | 'unix_socket' => env('DB_SOCKET', ''), 55 | 'charset' => 'utf8mb4', 56 | 'collation' => 'utf8mb4_unicode_ci', 57 | 'prefix' => '', 58 | 'prefix_indexes' => true, 59 | 'strict' => true, 60 | 'engine' => null, 61 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 62 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 63 | ]) : [], 64 | ], 65 | 66 | 'pgsql' => [ 67 | 'driver' => 'pgsql', 68 | 'url' => env('DATABASE_URL'), 69 | 'host' => env('DB_HOST', '127.0.0.1'), 70 | 'port' => env('DB_PORT', '5432'), 71 | 'database' => env('DB_DATABASE', 'forge'), 72 | 'username' => env('DB_USERNAME', 'forge'), 73 | 'password' => env('DB_PASSWORD', ''), 74 | 'charset' => 'utf8', 75 | 'prefix' => '', 76 | 'prefix_indexes' => true, 77 | 'schema' => 'public', 78 | 'sslmode' => 'prefer', 79 | ], 80 | 81 | 'sqlsrv' => [ 82 | 'driver' => 'sqlsrv', 83 | 'url' => env('DATABASE_URL'), 84 | 'host' => env('DB_HOST', 'localhost'), 85 | 'port' => env('DB_PORT', '1433'), 86 | 'database' => env('DB_DATABASE', 'forge'), 87 | 'username' => env('DB_USERNAME', 'forge'), 88 | 'password' => env('DB_PASSWORD', ''), 89 | 'charset' => 'utf8', 90 | 'prefix' => '', 91 | 'prefix_indexes' => true, 92 | ], 93 | 94 | 'dusk' => [ 95 | 'driver' => 'sqlite', 96 | 'url' => env('DATABASE_URL'), 97 | 'database' => database_path('dusk.sqlite'), 98 | 'prefix' => '', 99 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 100 | ], 101 | 102 | ], 103 | 104 | /* 105 | |-------------------------------------------------------------------------- 106 | | Migration Repository Table 107 | |-------------------------------------------------------------------------- 108 | | 109 | | This table keeps track of all the migrations that have already run for 110 | | your application. Using this information, we can determine which of 111 | | the migrations on disk haven't actually been run in the database. 112 | | 113 | */ 114 | 115 | 'migrations' => 'migrations', 116 | 117 | /* 118 | |-------------------------------------------------------------------------- 119 | | Redis Databases 120 | |-------------------------------------------------------------------------- 121 | | 122 | | Redis is an open source, fast, and advanced key-value store that also 123 | | provides a richer body of commands than a typical key-value system 124 | | such as APC or Memcached. Laravel makes it easy to dig right in. 125 | | 126 | */ 127 | 128 | 'redis' => [ 129 | 130 | 'client' => env('REDIS_CLIENT', 'phpredis'), 131 | 132 | 'options' => [ 133 | 'cluster' => env('REDIS_CLUSTER', 'redis'), 134 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), 135 | ], 136 | 137 | 'default' => [ 138 | 'url' => env('REDIS_URL'), 139 | 'host' => env('REDIS_HOST', '127.0.0.1'), 140 | 'password' => env('REDIS_PASSWORD', null), 141 | 'port' => env('REDIS_PORT', '6379'), 142 | 'database' => env('REDIS_DB', '0'), 143 | ], 144 | 145 | 'cache' => [ 146 | 'url' => env('REDIS_URL'), 147 | 'host' => env('REDIS_HOST', '127.0.0.1'), 148 | 'password' => env('REDIS_PASSWORD', null), 149 | 'port' => env('REDIS_PORT', '6379'), 150 | 'database' => env('REDIS_CACHE_DB', '1'), 151 | ], 152 | 153 | ], 154 | 155 | ]; 156 | -------------------------------------------------------------------------------- /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 | ], 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Symbolic Links 73 | |-------------------------------------------------------------------------- 74 | | 75 | | Here you may configure the symbolic links that will be created when the 76 | | `storage:link` Artisan command is executed. The array keys should be 77 | | the locations of the links and the values should be their targets. 78 | | 79 | */ 80 | 81 | 'links' => [ 82 | public_path('storage') => storage_path('app/public'), 83 | ], 84 | 85 | ]; 86 | -------------------------------------------------------------------------------- /config/hashing.php: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /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' => env('LOG_LEVEL', 'debug'), 48 | ], 49 | 50 | 'daily' => [ 51 | 'driver' => 'daily', 52 | 'path' => storage_path('logs/laravel.log'), 53 | 'level' => env('LOG_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' => env('LOG_LEVEL', 'critical'), 63 | ], 64 | 65 | 'papertrail' => [ 66 | 'driver' => 'monolog', 67 | 'level' => env('LOG_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' => env('LOG_LEVEL', 'debug'), 87 | ], 88 | 89 | 'errorlog' => [ 90 | 'driver' => 'errorlog', 91 | 'level' => env('LOG_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 | -------------------------------------------------------------------------------- /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/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-uuids'), 85 | 'database' => env('DB_CONNECTION', 'mysql'), 86 | 'table' => 'failed_jobs', 87 | ], 88 | 89 | ]; 90 | -------------------------------------------------------------------------------- /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 | 'github' => [ 34 | 'client_id' => env('GITHUB_CLIENT_ID'), 35 | 'client_secret' => env('GITHUB_CLIENT_SECRET'), 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | *.sqlite-journal 3 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | $this->faker->name, 27 | 'email' => $this->faker->unique()->safeEmail, 28 | 'email_verified_at' => now(), 29 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 30 | 'remember_token' => Str::random(10), 31 | ]; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->timestamp('email_verified_at')->nullable(); 21 | $table->string('password')->nullable(); 22 | $table->rememberToken(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('users'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /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/2017_12_07_122845_create_oauth_providers_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->bigInteger('user_id')->unsigned(); 19 | $table->string('provider'); 20 | $table->string('provider_user_id')->index(); 21 | $table->string('access_token')->nullable(); 22 | $table->string('refresh_token')->nullable(); 23 | $table->timestamps(); 24 | 25 | $table->foreign('user_id') 26 | ->references('id') 27 | ->on('users') 28 | ->onDelete('cascade'); 29 | }); 30 | } 31 | 32 | /** 33 | * Reverse the migrations. 34 | * 35 | * @return void 36 | */ 37 | public function down() 38 | { 39 | Schema::dropIfExists('oauth_providers'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('uuid')->unique(); 19 | $table->text('connection'); 20 | $table->text('queue'); 21 | $table->longText('payload'); 22 | $table->longText('exception'); 23 | $table->timestamp('failed_at')->useCurrent(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('failed_jobs'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "mix watch --hot", 5 | "watch": "mix watch", 6 | "build": "mix --production", 7 | "eslint": "eslint --fix --ext .js,.vue resources/js" 8 | }, 9 | "dependencies": { 10 | "@fortawesome/fontawesome-svg-core": "^1.2.36", 11 | "@fortawesome/free-brands-svg-icons": "^5.15.4", 12 | "@fortawesome/free-regular-svg-icons": "^5.15.4", 13 | "@fortawesome/free-solid-svg-icons": "^5.15.4", 14 | "@fortawesome/vue-fontawesome": "^2.0.2", 15 | "@popperjs/core": "^2.9.3", 16 | "axios": "^0.21.1", 17 | "bootstrap": "^5.1.0", 18 | "js-cookie": "^2.2.1", 19 | "sweetalert2": "^11.1.2", 20 | "vform": "^2.1.1", 21 | "vue": "^2.6.14", 22 | "vue-i18n": "^8.25.0", 23 | "vue-meta": "^2.4.0", 24 | "vue-router": "^3.5.2", 25 | "vuex": "^3.6.2", 26 | "vuex-router-sync": "^5.0.0" 27 | }, 28 | "devDependencies": { 29 | "@babel/core": "^7.15.0", 30 | "@babel/eslint-parser": "^7.15.0", 31 | "@babel/plugin-syntax-dynamic-import": "^7.8.3", 32 | "@babel/preset-env": "^7.15.0", 33 | "eslint": "^7.32.0", 34 | "eslint-config-standard": "^16.0.3", 35 | "eslint-plugin-import": "^2.24.0", 36 | "eslint-plugin-node": "^11.1.0", 37 | "eslint-plugin-promise": "^5.1.0", 38 | "eslint-plugin-standard": "^5.0.0", 39 | "eslint-plugin-vue": "^7.16.0", 40 | "laravel-mix": "^6.0.27", 41 | "laravel-mix-versionhash": "^2.0.1", 42 | "resolve-url-loader": "^4.0.0", 43 | "sass": "^1.37.5", 44 | "sass-loader": "^12.1.0", 45 | "vue-loader": "^15.9.8", 46 | "vue-template-compiler": "^2.6.14", 47 | "webpack-bundle-analyzer": "^4.4.2" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /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 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cretueusebiu/laravel-vue-spa/d395d99142325298e36cf0515bb6e469062c9c04/public/favicon.ico -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class); 50 | 51 | $response = tap($kernel->handle( 52 | $request = Request::capture() 53 | ))->send(); 54 | 55 | $kernel->terminate($request, $response); 56 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /public/web.config: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /resources/js/app.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import store from '~/store' 3 | import router from '~/router' 4 | import i18n from '~/plugins/i18n' 5 | import App from '~/components/App' 6 | 7 | import '~/plugins' 8 | import '~/components' 9 | 10 | Vue.config.productionTip = false 11 | 12 | /* eslint-disable no-new */ 13 | new Vue({ 14 | i18n, 15 | store, 16 | router, 17 | ...App 18 | }) 19 | -------------------------------------------------------------------------------- /resources/js/components/App.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 67 | -------------------------------------------------------------------------------- /resources/js/components/Button.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 45 | -------------------------------------------------------------------------------- /resources/js/components/Card.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 22 | -------------------------------------------------------------------------------- /resources/js/components/Checkbox.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 67 | -------------------------------------------------------------------------------- /resources/js/components/Child.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 14 | -------------------------------------------------------------------------------- /resources/js/components/Loading.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 87 | 88 | 102 | -------------------------------------------------------------------------------- /resources/js/components/LocaleDropdown.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 39 | -------------------------------------------------------------------------------- /resources/js/components/LoginWithGithub.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 87 | -------------------------------------------------------------------------------- /resources/js/components/Navbar.vue: -------------------------------------------------------------------------------- 1 | 60 | 61 | 89 | 90 | 101 | -------------------------------------------------------------------------------- /resources/js/components/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Card from './Card.vue' 3 | import Child from './Child.vue' 4 | import Button from './Button.vue' 5 | import Checkbox from './Checkbox.vue' 6 | import { HasError, AlertError, AlertSuccess } from 'vform/components/bootstrap5' 7 | 8 | // Components that are registered globaly. 9 | [ 10 | Card, 11 | Child, 12 | Button, 13 | Checkbox, 14 | HasError, 15 | AlertError, 16 | AlertSuccess 17 | ].forEach(Component => { 18 | Vue.component(Component.name, Component) 19 | }) 20 | -------------------------------------------------------------------------------- /resources/js/lang/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "ok": "Ok", 3 | "cancel": "Cancel", 4 | "error_alert_title": "Oops...", 5 | "error_alert_text": "Something went wrong! Please try again.", 6 | "token_expired_alert_title": "Session Expired!", 7 | "token_expired_alert_text": "Please log in again to continue.", 8 | "login": "Log In", 9 | "register": "Register", 10 | "page_not_found": "Page Not Found", 11 | "go_home": "Go Home", 12 | "logout": "Logout", 13 | "email": "Email", 14 | "remember_me": "Remember Me", 15 | "password": "Password", 16 | "forgot_password": "Forgot Your Password?", 17 | "confirm_password": "Confirm Password", 18 | "name": "Name", 19 | "toggle_navigation": "Toggle navigation", 20 | "home": "Home", 21 | "you_are_logged_in": "You are logged in!", 22 | "reset_password": "Reset Password", 23 | "send_password_reset_link": "Send Password Reset Link", 24 | "settings": "Settings", 25 | "profile": "Profile", 26 | "your_info": "Your Info", 27 | "info_updated": "Your info has been updated!", 28 | "update": "Update", 29 | "your_password": "Your Password", 30 | "password_updated": "Your password has been updated!", 31 | "new_password": "New Password", 32 | "login_with": "Login with", 33 | "register_with": "Register with", 34 | "verify_email": "Verify Email", 35 | "send_verification_link": "Send Verification Link", 36 | "resend_verification_link": "Resend Verification Link ?", 37 | "failed_to_verify_email": "Failed to verify email.", 38 | "verify_email_address": "We sent you an email with an the verification link." 39 | } 40 | -------------------------------------------------------------------------------- /resources/js/lang/es.json: -------------------------------------------------------------------------------- 1 | { 2 | "ok": "De Acuerdo", 3 | "cancel": "Cancelar", 4 | "error_alert_title": "Ha ocurrido un problema", 5 | "error_alert_text": "¡Algo salió mal! Inténtalo de nuevo.", 6 | "token_expired_alert_title": "!Sesión Expirada!", 7 | "token_expired_alert_text": "Por favor inicie sesión de nuevo para continuar.", 8 | "login": "Iniciar Sesión", 9 | "register": "Registro", 10 | "page_not_found": "Página No Encontrada", 11 | "go_home": "Ir a Inicio", 12 | "logout": "Cerrar Sesión", 13 | "email": "Correo Electrónico", 14 | "remember_me": "Recuérdame", 15 | "password": "Contraseña", 16 | "forgot_password": "¿Olvidaste tu contraseña?", 17 | "confirm_password": "Confirmar Contraseña", 18 | "name": "Nombre", 19 | "toggle_navigation": "Cambiar Navegación", 20 | "home": "Inicio", 21 | "you_are_logged_in": "¡Has iniciado sesión!", 22 | "reset_password": "Restablecer la contraseña", 23 | "send_password_reset_link": "Enviar Enlace de Restablecimiento de Contraseña", 24 | "settings": "Configuraciones", 25 | "profile": "Perfil", 26 | "your_info": "Tu Información", 27 | "info_updated": "¡Tu información ha sido actualizada!", 28 | "update": "Actualizar", 29 | "your_password": "Tu Contraseña", 30 | "password_updated": "¡Tu contraseña ha sido actualizada!", 31 | "new_password": "Nueva Contraseña", 32 | "login_with": "Iniciar Sesión con", 33 | "register_with": "Registro con" 34 | } 35 | -------------------------------------------------------------------------------- /resources/js/lang/fr.json: -------------------------------------------------------------------------------- 1 | { 2 | "ok": "Ok", 3 | "cancel": "Annuler", 4 | "error_alert_title": "Oups...", 5 | "error_alert_text": "Quelque chose a mal tourné ! Veuillez réessayer.", 6 | "token_expired_alert_title": "Session expirée !", 7 | "token_expired_alert_text": "Veuillez vous reconnecter pour continuer.", 8 | "login": "Connexion", 9 | "register": "Inscription", 10 | "page_not_found": "Page non trouvée", 11 | "go_home": "Retour à l'accueil", 12 | "logout": "Déconnexion", 13 | "email": "Email", 14 | "remember_me": "Se souvenir de moi", 15 | "password": "Mot de passe", 16 | "forgot_password": "Vous avez oublié votre mot de passe ?", 17 | "confirm_password": "Confirmer le mot de passe", 18 | "name": "Nom", 19 | "toggle_navigation": "Basculer la navigation", 20 | "home": "Accueil", 21 | "you_are_logged_in": "Vous êtes connecté !", 22 | "reset_password": "Réinitialisation du mot de passe", 23 | "send_password_reset_link": "Envoyer le lien de réinitialisation du mot de passe", 24 | "settings": "Paramètres", 25 | "profile": "Profil", 26 | "your_info": "Vos informations", 27 | "info_updated": "Vos informations ont été mises à jour !", 28 | "update": "Mettre à jour", 29 | "your_password": "Votre mot de passe", 30 | "password_updated": "Votre mot de passe a été mis à jour !", 31 | "new_password": "Nouveau mot de passe", 32 | "login_with": "Connectez-vous avec", 33 | "register_with": "S'inscrire avec", 34 | "verify_email": "Vérifier l'e-mail", 35 | "send_verification_link": "Envoyer le lien de vérification", 36 | "resend_verification_link": "Renvoyer le lien de vérification ?", 37 | "failed_to_verify_email": "Nous n'avons pas réussi à vérifier votre email.", 38 | "verify_email_address": "Nous vous avons envoyé un e-mail avec un lien de vérification." 39 | } 40 | -------------------------------------------------------------------------------- /resources/js/lang/pt-BR.json: -------------------------------------------------------------------------------- 1 | { 2 | "ok": "Ok", 3 | "cancel": "Cancelar", 4 | "error_alert_title": "Oops...", 5 | "error_alert_text": "Algo deu errado! Por favor, tente novamente.", 6 | "token_expired_alert_title": "Sessão expirada!", 7 | "token_expired_alert_text": "Faça login novamente para continuar.", 8 | "login": "Entrar", 9 | "register": "Cadastrar", 10 | "page_not_found": "Página não encontrada", 11 | "go_home": "Inicio", 12 | "logout": "Sair", 13 | "email": "Email", 14 | "remember_me": "Lembre-me", 15 | "password": "Senha", 16 | "forgot_password": "Esqueceu sua senha?", 17 | "confirm_password": "Confirmar Senha", 18 | "name": "Nome", 19 | "toggle_navigation": "Alternar de navegação", 20 | "home": "Inicio", 21 | "you_are_logged_in": "Você está logado!", 22 | "reset_password": "Trocar Senha", 23 | "send_password_reset_link": "Enviar link de redefinição de senha", 24 | "settings": "Configurações", 25 | "profile": "Perfil", 26 | "your_info": "Suas informações", 27 | "info_updated": "Suas informações foram atualizadas!", 28 | "update": "Atualizar", 29 | "your_password": "Sua senha", 30 | "password_updated": "Sua senha foi atualizada!", 31 | "new_password": "Nova Senha", 32 | "login_with": "Entrar", 33 | "register_with": "Registre-se", 34 | "verify_email": "verificar email", 35 | "send_verification_link": "Enviar link de verificação", 36 | "resend_verification_link": "Reenviar link de verificação?", 37 | "failed_to_verify_email": "Falha ao verificar o email.", 38 | "verify_email_address": "Enviamos um e-mail com o link de verificação." 39 | } 40 | -------------------------------------------------------------------------------- /resources/js/lang/zh-CN.json: -------------------------------------------------------------------------------- 1 | { 2 | "ok": "确定", 3 | "cancel": "取消", 4 | "error_alert_title": "错误...", 5 | "error_alert_text": "遇到一些错误,请稍后重试~", 6 | "token_expired_alert_title": "验证过期!", 7 | "token_expired_alert_text": "请稍后重新登录系统", 8 | "login": "登录", 9 | "register": "注册", 10 | "page_not_found": "页面不存在", 11 | "go_home": "返回首页", 12 | "logout": "退出", 13 | "email": "邮箱", 14 | "remember_me": "记住我", 15 | "password": "密码", 16 | "forgot_password": "忘记密码?", 17 | "confirm_password": "重复密码", 18 | "name": "用户名", 19 | "toggle_navigation": "切换导航", 20 | "home": "首页", 21 | "you_are_logged_in": "您已经登录!", 22 | "reset_password": "重置密码", 23 | "send_password_reset_link": "发送重置链接", 24 | "settings": "设置", 25 | "profile": "个人设置", 26 | "your_info": "您的个人信息", 27 | "info_updated": "您的个人信息已经更改!", 28 | "update": "更新", 29 | "your_password": "您的密码", 30 | "password_updated": "您的密码已经更新!", 31 | "new_password": "新密码", 32 | "login_with": "登录", 33 | "register_with": "注册" 34 | } 35 | -------------------------------------------------------------------------------- /resources/js/layouts/basic.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 31 | -------------------------------------------------------------------------------- /resources/js/layouts/default.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 22 | -------------------------------------------------------------------------------- /resources/js/layouts/error.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 13 | -------------------------------------------------------------------------------- /resources/js/middleware/admin.js: -------------------------------------------------------------------------------- 1 | import store from '~/store' 2 | 3 | export default (to, from, next) => { 4 | if (store.getters['auth/user'].role !== 'admin') { 5 | next({ name: 'home' }) 6 | } else { 7 | next() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /resources/js/middleware/auth.js: -------------------------------------------------------------------------------- 1 | import store from '~/store' 2 | import Cookies from 'js-cookie' 3 | 4 | export default async (to, from, next) => { 5 | if (!store.getters['auth/check']) { 6 | Cookies.set('intended_url', to.path) 7 | 8 | next({ name: 'login' }) 9 | } else { 10 | next() 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /resources/js/middleware/check-auth.js: -------------------------------------------------------------------------------- 1 | import store from '~/store' 2 | 3 | export default async (to, from, next) => { 4 | if (!store.getters['auth/check'] && store.getters['auth/token']) { 5 | try { 6 | await store.dispatch('auth/fetchUser') 7 | } catch (e) { } 8 | } 9 | 10 | next() 11 | } 12 | -------------------------------------------------------------------------------- /resources/js/middleware/guest.js: -------------------------------------------------------------------------------- 1 | import store from '~/store' 2 | 3 | export default (to, from, next) => { 4 | if (store.getters['auth/check']) { 5 | next({ name: 'home' }) 6 | } else { 7 | next() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /resources/js/middleware/locale.js: -------------------------------------------------------------------------------- 1 | import store from '~/store' 2 | import { loadMessages } from '~/plugins/i18n' 3 | 4 | export default async (to, from, next) => { 5 | await loadMessages(store.getters['lang/locale']) 6 | 7 | next() 8 | } 9 | -------------------------------------------------------------------------------- /resources/js/middleware/role.js: -------------------------------------------------------------------------------- 1 | import store from '~/store' 2 | 3 | /** 4 | * This is middleware to check the current user role. 5 | * 6 | * middleware: 'role:admin,manager', 7 | */ 8 | 9 | export default (to, from, next, roles) => { 10 | // Grab the user 11 | const user = store.getters['auth/user'] 12 | 13 | // Split roles into an array 14 | roles = roles.split(',') 15 | 16 | // Check if the user has one of the required roles... 17 | if (!roles.includes(user.role)) { 18 | next('/unauthorized') 19 | } 20 | 21 | next() 22 | } 23 | -------------------------------------------------------------------------------- /resources/js/pages/auth/login.vue: -------------------------------------------------------------------------------- 1 | 54 | 55 | 110 | -------------------------------------------------------------------------------- /resources/js/pages/auth/password/email.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 59 | -------------------------------------------------------------------------------- /resources/js/pages/auth/password/reset.vue: -------------------------------------------------------------------------------- 1 | 48 | 49 | 85 | -------------------------------------------------------------------------------- /resources/js/pages/auth/register.vue: -------------------------------------------------------------------------------- 1 | 63 | 64 | 114 | -------------------------------------------------------------------------------- /resources/js/pages/auth/verification/resend.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 65 | -------------------------------------------------------------------------------- /resources/js/pages/auth/verification/verify.vue: -------------------------------------------------------------------------------- 1 | 27 | 28 | 56 | -------------------------------------------------------------------------------- /resources/js/pages/errors/404.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 20 | -------------------------------------------------------------------------------- /resources/js/pages/home.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 29 | -------------------------------------------------------------------------------- /resources/js/pages/settings/index.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 46 | 47 | 52 | -------------------------------------------------------------------------------- /resources/js/pages/settings/password.vue: -------------------------------------------------------------------------------- 1 | 35 | 36 | 62 | -------------------------------------------------------------------------------- /resources/js/pages/settings/profile.vue: -------------------------------------------------------------------------------- 1 | 35 | 36 | 74 | -------------------------------------------------------------------------------- /resources/js/pages/welcome.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 50 | 51 | 62 | -------------------------------------------------------------------------------- /resources/js/plugins/axios.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import Swal from 'sweetalert2/dist/sweetalert2.js' 3 | import store from '~/store' 4 | import router from '~/router' 5 | import i18n from '~/plugins/i18n' 6 | 7 | // Request interceptor 8 | axios.interceptors.request.use(request => { 9 | const token = store.getters['auth/token'] 10 | if (token) { 11 | request.headers.common.Authorization = `Bearer ${token}` 12 | } 13 | 14 | const locale = store.getters['lang/locale'] 15 | if (locale) { 16 | request.headers.common['Accept-Language'] = locale 17 | } 18 | 19 | // request.headers['X-Socket-Id'] = Echo.socketId() 20 | 21 | return request 22 | }) 23 | 24 | // Response interceptor 25 | axios.interceptors.response.use(response => response, error => { 26 | const { status } = error.response 27 | 28 | if (status === 401 && store.getters['auth/check']) { 29 | Swal.fire({ 30 | icon: 'warning', 31 | title: i18n.t('token_expired_alert_title'), 32 | text: i18n.t('token_expired_alert_text'), 33 | reverseButtons: true, 34 | confirmButtonText: i18n.t('ok'), 35 | cancelButtonText: i18n.t('cancel') 36 | }).then(() => { 37 | store.commit('auth/LOGOUT') 38 | 39 | router.push({ name: 'login' }) 40 | }) 41 | } 42 | 43 | if (status >= 500) { 44 | serverError(error.response) 45 | } 46 | 47 | return Promise.reject(error) 48 | }) 49 | 50 | let serverErrorModalShown = false 51 | async function serverError (response) { 52 | if (serverErrorModalShown) { 53 | return 54 | } 55 | 56 | if ((response.headers['content-type'] || '').includes('text/html')) { 57 | const iframe = document.createElement('iframe') 58 | 59 | if (response.data instanceof Blob) { 60 | iframe.srcdoc = await response.data.text() 61 | } else { 62 | iframe.srcdoc = response.data 63 | } 64 | 65 | Swal.fire({ 66 | html: iframe.outerHTML, 67 | showConfirmButton: false, 68 | customClass: { container: 'server-error-modal' }, 69 | didDestroy: () => { serverErrorModalShown = false }, 70 | grow: 'fullscreen', 71 | padding: 0 72 | }) 73 | 74 | serverErrorModalShown = true 75 | } else { 76 | Swal.fire({ 77 | icon: 'error', 78 | title: i18n.t('error_alert_title'), 79 | text: i18n.t('error_alert_text'), 80 | reverseButtons: true, 81 | confirmButtonText: i18n.t('ok'), 82 | cancelButtonText: i18n.t('cancel') 83 | }) 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /resources/js/plugins/fontawesome.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import { library, config } from '@fortawesome/fontawesome-svg-core' 3 | import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' 4 | 5 | // import { } from '@fortawesome/free-regular-svg-icons' 6 | 7 | import { 8 | faUser, faLock, faSignOutAlt, faCog 9 | } from '@fortawesome/free-solid-svg-icons' 10 | 11 | import { 12 | faGithub 13 | } from '@fortawesome/free-brands-svg-icons' 14 | 15 | config.autoAddCss = false 16 | 17 | library.add( 18 | faUser, faLock, faSignOutAlt, faCog, faGithub 19 | ) 20 | 21 | Vue.component('Fa', FontAwesomeIcon) 22 | -------------------------------------------------------------------------------- /resources/js/plugins/i18n.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import store from '~/store' 3 | import VueI18n from 'vue-i18n' 4 | 5 | Vue.use(VueI18n) 6 | 7 | const i18n = new VueI18n({ 8 | locale: 'en', 9 | messages: {} 10 | }) 11 | 12 | /** 13 | * @param {String} locale 14 | */ 15 | export async function loadMessages (locale) { 16 | if (Object.keys(i18n.getLocaleMessage(locale)).length === 0) { 17 | const messages = await import(/* webpackChunkName: '' */ `~/lang/${locale}`) 18 | i18n.setLocaleMessage(locale, messages) 19 | } 20 | 21 | if (i18n.locale !== locale) { 22 | i18n.locale = locale 23 | } 24 | } 25 | 26 | ;(async function () { 27 | await loadMessages(store.getters['lang/locale']) 28 | })() 29 | 30 | export default i18n 31 | -------------------------------------------------------------------------------- /resources/js/plugins/index.js: -------------------------------------------------------------------------------- 1 | import './axios' 2 | import './fontawesome' 3 | import 'bootstrap' 4 | -------------------------------------------------------------------------------- /resources/js/router/routes.js: -------------------------------------------------------------------------------- 1 | function page (path) { 2 | return () => import(/* webpackChunkName: '' */ `~/pages/${path}`).then(m => m.default || m) 3 | } 4 | 5 | export default [ 6 | { path: '/', name: 'welcome', component: page('welcome.vue') }, 7 | 8 | { path: '/login', name: 'login', component: page('auth/login.vue') }, 9 | { path: '/register', name: 'register', component: page('auth/register.vue') }, 10 | { path: '/password/reset', name: 'password.request', component: page('auth/password/email.vue') }, 11 | { path: '/password/reset/:token', name: 'password.reset', component: page('auth/password/reset.vue') }, 12 | { path: '/email/verify/:id', name: 'verification.verify', component: page('auth/verification/verify.vue') }, 13 | { path: '/email/resend', name: 'verification.resend', component: page('auth/verification/resend.vue') }, 14 | 15 | { path: '/home', name: 'home', component: page('home.vue') }, 16 | { 17 | path: '/settings', 18 | component: page('settings/index.vue'), 19 | children: [ 20 | { path: '', redirect: { name: 'settings.profile' } }, 21 | { path: 'profile', name: 'settings.profile', component: page('settings/profile.vue') }, 22 | { path: 'password', name: 'settings.password', component: page('settings/password.vue') } 23 | ] 24 | }, 25 | 26 | { path: '*', component: page('errors/404.vue') } 27 | ] 28 | -------------------------------------------------------------------------------- /resources/js/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | 4 | Vue.use(Vuex) 5 | 6 | // Load store modules dynamically. 7 | const requireContext = require.context('./modules', false, /.*\.js$/) 8 | 9 | const modules = requireContext.keys() 10 | .map(file => 11 | [file.replace(/(^.\/)|(\.js$)/g, ''), requireContext(file)] 12 | ) 13 | .reduce((modules, [name, module]) => { 14 | if (module.namespaced === undefined) { 15 | module.namespaced = true 16 | } 17 | 18 | return { ...modules, [name]: module } 19 | }, {}) 20 | 21 | export default new Vuex.Store({ 22 | modules 23 | }) 24 | -------------------------------------------------------------------------------- /resources/js/store/modules/auth.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import Cookies from 'js-cookie' 3 | import * as types from '../mutation-types' 4 | 5 | // state 6 | export const state = { 7 | user: null, 8 | token: Cookies.get('token') 9 | } 10 | 11 | // getters 12 | export const getters = { 13 | user: state => state.user, 14 | token: state => state.token, 15 | check: state => state.user !== null 16 | } 17 | 18 | // mutations 19 | export const mutations = { 20 | [types.SAVE_TOKEN] (state, { token, remember }) { 21 | state.token = token 22 | Cookies.set('token', token, { expires: remember ? 365 : null }) 23 | }, 24 | 25 | [types.FETCH_USER_SUCCESS] (state, { user }) { 26 | state.user = user 27 | }, 28 | 29 | [types.FETCH_USER_FAILURE] (state) { 30 | state.token = null 31 | Cookies.remove('token') 32 | }, 33 | 34 | [types.LOGOUT] (state) { 35 | state.user = null 36 | state.token = null 37 | 38 | Cookies.remove('token') 39 | }, 40 | 41 | [types.UPDATE_USER] (state, { user }) { 42 | state.user = user 43 | } 44 | } 45 | 46 | // actions 47 | export const actions = { 48 | saveToken ({ commit, dispatch }, payload) { 49 | commit(types.SAVE_TOKEN, payload) 50 | }, 51 | 52 | async fetchUser ({ commit }) { 53 | try { 54 | const { data } = await axios.get('/api/user') 55 | 56 | commit(types.FETCH_USER_SUCCESS, { user: data }) 57 | } catch (e) { 58 | commit(types.FETCH_USER_FAILURE) 59 | } 60 | }, 61 | 62 | updateUser ({ commit }, payload) { 63 | commit(types.UPDATE_USER, payload) 64 | }, 65 | 66 | async logout ({ commit }) { 67 | try { 68 | await axios.post('/api/logout') 69 | } catch (e) { } 70 | 71 | commit(types.LOGOUT) 72 | }, 73 | 74 | async fetchOauthUrl (ctx, { provider }) { 75 | const { data } = await axios.post(`/api/oauth/${provider}`) 76 | 77 | return data.url 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /resources/js/store/modules/lang.js: -------------------------------------------------------------------------------- 1 | import Cookies from 'js-cookie' 2 | import * as types from '../mutation-types' 3 | 4 | const { locale, locales } = window.config 5 | 6 | // state 7 | export const state = { 8 | locale: getLocale(locales, locale), 9 | locales: locales 10 | } 11 | 12 | // getters 13 | export const getters = { 14 | locale: state => state.locale, 15 | locales: state => state.locales 16 | } 17 | 18 | // mutations 19 | export const mutations = { 20 | [types.SET_LOCALE] (state, { locale }) { 21 | state.locale = locale 22 | } 23 | } 24 | 25 | // actions 26 | export const actions = { 27 | setLocale ({ commit }, { locale }) { 28 | commit(types.SET_LOCALE, { locale }) 29 | 30 | Cookies.set('locale', locale, { expires: 365 }) 31 | } 32 | } 33 | 34 | /** 35 | * @param {String[]} locales 36 | * @param {String} fallback 37 | * @return {String} 38 | */ 39 | function getLocale (locales, fallback) { 40 | const locale = Cookies.get('locale') 41 | 42 | if (Object.prototype.hasOwnProperty.call(locales, locale)) { 43 | return locale 44 | } else if (locale) { 45 | Cookies.remove('locale') 46 | } 47 | 48 | return fallback 49 | } 50 | -------------------------------------------------------------------------------- /resources/js/store/mutation-types.js: -------------------------------------------------------------------------------- 1 | // auth.js 2 | export const LOGOUT = 'LOGOUT' 3 | export const SAVE_TOKEN = 'SAVE_TOKEN' 4 | export const FETCH_USER = 'FETCH_USER' 5 | export const FETCH_USER_SUCCESS = 'FETCH_USER_SUCCESS' 6 | export const FETCH_USER_FAILURE = 'FETCH_USER_FAILURE' 7 | export const UPDATE_USER = 'UPDATE_USER' 8 | 9 | // lang.js 10 | export const SET_LOCALE = 'SET_LOCALE' 11 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /resources/lang/en/verification.php: -------------------------------------------------------------------------------- 1 | 'Your email has been verified!', 6 | 'invalid' => 'The verification link is invalid.', 7 | 'already_verified' => 'The email is already verified.', 8 | 'user' => 'We can\'t find a user with that e-mail address.', 9 | 'sent' => 'We have e-mailed your verification link!', 10 | 11 | ]; 12 | -------------------------------------------------------------------------------- /resources/lang/es/auth.php: -------------------------------------------------------------------------------- 1 | 'Estas credenciales no coinciden con nuestros registros.', 17 | 'throttle' => 'Demasiados intentos de acceso. Por favor intente nuevamente en :seconds segundos.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/es/pagination.php: -------------------------------------------------------------------------------- 1 | '« Anterior', 17 | 'next' => 'Siguiente »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/es/passwords.php: -------------------------------------------------------------------------------- 1 | 'Las contraseñas deben coincidir y contener al menos 6 caracteres', 17 | 'reset' => '¡Tu contraseña ha sido restablecida!', 18 | 'sent' => '¡Te hemos enviado por correo el enlace para restablecer tu contraseña!', 19 | 'token' => 'El token de recuperación de contraseña es inválido.', 20 | 'user' => 'No podemos encontrar ningún usuario con ese correo electrónico.', 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /resources/lang/pt-BR/auth.php: -------------------------------------------------------------------------------- 1 | 'Credenciais informadas não correspondem com nossos registros.', 16 | 'throttle' => 'Você realizou muitas tentativas de login. Por favor, tente novamente em :seconds segundos.', 17 | ]; 18 | -------------------------------------------------------------------------------- /resources/lang/pt-BR/pagination.php: -------------------------------------------------------------------------------- 1 | '« Anterior', 16 | 'next' => 'Próxima »', 17 | ]; 18 | -------------------------------------------------------------------------------- /resources/lang/pt-BR/passwords.php: -------------------------------------------------------------------------------- 1 | 'A senha deve conter pelo menos oito caracteres e ser igual à confirmação.', 16 | 'reset' => 'Sua senha foi redefinida!', 17 | 'sent' => 'Enviamos um link para redefinir a sua senha por e-mail.', 18 | 'token' => 'Esse código de redefinição de senha é inválido.', 19 | 'user' => 'Não conseguimos encontrar nenhum usuário com o endereço de e-mail informado.', 20 | ]; 21 | -------------------------------------------------------------------------------- /resources/lang/zh-CN/auth.php: -------------------------------------------------------------------------------- 1 | '用户名或手机号与密码不匹配或用户被禁用', 15 | 'throttle' => '失败次数太多,请在:seconds秒后再尝试', 16 | ]; 17 | -------------------------------------------------------------------------------- /resources/lang/zh-CN/pagination.php: -------------------------------------------------------------------------------- 1 | '« 上一页', 15 | 'next' => '下一页 »', 16 | ]; 17 | -------------------------------------------------------------------------------- /resources/lang/zh-CN/passwords.php: -------------------------------------------------------------------------------- 1 | '密码长度至少包含6个字符并且两次输入密码要一致', 15 | 'reset' => '密码已经被重置!', 16 | 'sent' => '我们已经发送密码重置链接到您的邮箱', 17 | 'token' => '密码重置令牌无效', 18 | 'user' => '抱歉,该邮箱对应的用户不存在!', 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/zh-CN/validation.php: -------------------------------------------------------------------------------- 1 | ':attribute 已存在', 15 | 'accepted' => ':attribute 是被接受的', 16 | 'active_url' => ':attribute 必须是一个合法的 URL', 17 | 'after' => ':attribute 必须是 :date 之后的一个日期', 18 | 'alpha' => ':attribute 必须全部由字母字符构成。', 19 | 'alpha_dash' => ':attribute 必须全部由字母、数字、中划线或下划线字符构成', 20 | 'alpha_num' => ':attribute 必须全部由字母和数字构成', 21 | 'array' => ':attribute 必须是个数组', 22 | 'before' => ':attribute 必须是 :date 之前的一个日期', 23 | 'between' => [ 24 | 'numeric' => ':attribute 必须在 :min 到 :max 之间', 25 | 'file' => ':attribute 必须在 :min 到 :max KB之间', 26 | 'string' => ':attribute 必须在 :min 到 :max 个字符之间', 27 | 'array' => ':attribute 必须在 :min 到 :max 项之间', 28 | ], 29 | 'boolean' => ':attribute 字符必须是 true 或 false', 30 | 'confirmed' => ':attribute 两次确认不匹配', 31 | 'date' => ':attribute 必须是一个合法的日期', 32 | 'date_format' => ':attribute 与给定的格式 :format 不符合', 33 | 'different' => ':attribute 必须不同于:other', 34 | 'digits' => ':attribute 必须是 :digits 位', 35 | 'digits_between' => ':attribute 必须在 :min and :max 位之间', 36 | 'email' => ':attribute 必须是一个合法的电子邮件地址。', 37 | 'filled' => ':attribute 的字段是必填的', 38 | 'exists' => '选定的 :attribute 是无效的', 39 | 'image' => ':attribute 必须是一个图片 (jpeg, png, bmp 或者 gif)', 40 | 'in' => '选定的 :attribute 是无效的', 41 | 'integer' => ':attribute 必须是个整数', 42 | 'ip' => ':attribute 必须是一个合法的 IP 地址。', 43 | 'max' => [ 44 | 'numeric' => ':attribute 的最大长度为 :max 位', 45 | 'file' => ':attribute 的最大为 :max', 46 | 'string' => ':attribute 的最大长度为 :max 字符', 47 | 'array' => ':attribute 的最大个数为 :max 个', 48 | ], 49 | 'mimes' => ':attribute 的文件类型必须是:values', 50 | 'mimetypes' => ':attribute 的文件类型必须是: :values.', 51 | 'min' => [ 52 | 'numeric' => ':attribute 的最小长度为 :min 位', 53 | 'string' => ':attribute 的最小长度为 :min 字符', 54 | 'file' => ':attribute 大小至少为:min KB', 55 | 'array' => ':attribute 至少有 :min 项', 56 | ], 57 | 'not_in' => '选定的 :attribute 是无效的', 58 | 'numeric' => ':attribute 必须是数字', 59 | 'regex' => ':attribute 格式是无效的', 60 | 'required' => ':attribute 字段必须填写', 61 | 'required_if' => ':attribute 字段是必须的当 :other 是 :value', 62 | 'required_with' => ':attribute 字段是必须的当 :values 是存在的', 63 | 'required_with_all' => ':attribute 字段是必须的当 :values 是存在的', 64 | 'required_without' => ':attribute 字段是必须的当 :values 是不存在的', 65 | 'required_without_all' => ':attribute 字段是必须的当 没有一个 :values 是存在的', 66 | 'same' => ':attribute 和 :other 必须匹配', 67 | 'size' => [ 68 | 'numeric' => ':attribute 必须是 :size 位', 69 | 'file' => ':attribute 必须是 :size KB', 70 | 'string' => ':attribute 必须是 :size 个字符', 71 | 'array' => ':attribute 必须包括 :size 项', 72 | ], 73 | 'url' => ':attribute 无效的格式', 74 | 'timezone' => ':attribute 必须个有效的时区', 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Custom Validation Language Lines 78 | |-------------------------------------------------------------------------- 79 | | 80 | | Here you may specify custom validation messages for attributes using the 81 | | convention "attribute.rule" to name the lines. This makes it quick to 82 | | specify a specific custom language line for a given attribute rule. 83 | | 84 | */ 85 | 'custom' => [], 86 | /* 87 | |-------------------------------------------------------------------------- 88 | | Custom Validation Attributes 89 | |-------------------------------------------------------------------------- 90 | | 91 | | The following language lines are used to swap attribute place-holders 92 | | with something more reader friendly such as E-Mail Address instead 93 | | of "email". This simply helps us make messages a little cleaner. 94 | | 95 | */ 96 | 'attributes' => [], 97 | ]; 98 | -------------------------------------------------------------------------------- /resources/sass/_variables.scss: -------------------------------------------------------------------------------- 1 | // Body 2 | $body-bg: #f7f9fb; 3 | 4 | // Links 5 | $link-decoration: none; 6 | $link-hover-decoration: underline; 7 | 8 | // Cards 9 | $card-cap-bg: #fbfbfb; 10 | $card-border-color: #e8eced; 11 | 12 | // Borders 13 | $border-radius: .125rem; 14 | $border-radius-lg: .2rem; 15 | $border-radius-sm: .15rem; 16 | 17 | // Nav Pills 18 | $nav-pills-border-radius: 0; 19 | -------------------------------------------------------------------------------- /resources/sass/app.scss: -------------------------------------------------------------------------------- 1 | @import 'variables'; 2 | 3 | @import '~bootstrap/scss/bootstrap'; 4 | @import '~sweetalert2/dist/sweetalert2'; 5 | @import '~@fortawesome/fontawesome-svg-core/styles'; 6 | 7 | @import 'elements/card'; 8 | @import 'elements/navbar'; 9 | @import 'elements/buttons'; 10 | @import 'elements/transitions'; 11 | 12 | @import 'components/server-error'; 13 | -------------------------------------------------------------------------------- /resources/sass/components/_server-error.scss: -------------------------------------------------------------------------------- 1 | .server-error-modal { 2 | height: 100%; 3 | 4 | .swal2-html-container { 5 | margin: 0; 6 | overflow: hidden; 7 | } 8 | 9 | iframe { 10 | width: 100%; 11 | height: 100%; 12 | border: none; 13 | border-radius: 5px; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /resources/sass/elements/_buttons.scss: -------------------------------------------------------------------------------- 1 | .btn-loading { 2 | position: relative; 3 | pointer-events: none; 4 | color: transparent !important; 5 | 6 | &:after { 7 | animation: spinAround 500ms infinite linear; 8 | border: 2px solid #dbdbdb; 9 | border-radius: 50%; 10 | border-right-color: transparent; 11 | border-top-color: transparent; 12 | content: ""; 13 | display: block; 14 | height: 1em; 15 | width: 1em; 16 | position: absolute; 17 | left: calc(50% - (1em / 2)); 18 | top: calc(50% - (1em / 2)); 19 | } 20 | } 21 | 22 | @keyframes spinAround { 23 | from { transform: rotate(0deg); } 24 | to { transform: rotate(359deg); } 25 | } 26 | -------------------------------------------------------------------------------- /resources/sass/elements/_card.scss: -------------------------------------------------------------------------------- 1 | .card { 2 | box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05); 3 | } 4 | -------------------------------------------------------------------------------- /resources/sass/elements/_navbar.scss: -------------------------------------------------------------------------------- 1 | .navbar { 2 | font-weight: 600; 3 | box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1); 4 | } 5 | 6 | .nav-item { 7 | .dropdown-menu { 8 | border: none; 9 | margin-top: .5rem; 10 | border-top: 1px solid #f2f2f2 !important; 11 | box-shadow: 0 4px 8px 0 rgba(0,0,0,0.12), 0 2px 4px 0 rgba(0,0,0,0.08); 12 | } 13 | } 14 | 15 | .nav-link { 16 | .svg-inline--fa { 17 | font-size: 1.4rem; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /resources/sass/elements/_transitions.scss: -------------------------------------------------------------------------------- 1 | .page-enter-active, 2 | .page-leave-active { 3 | transition: opacity .2s; 4 | } 5 | .page-enter, 6 | .page-leave-to { 7 | opacity: 0; 8 | } 9 | 10 | .fade-enter-active, 11 | .fade-leave-active { 12 | transition: opacity .15s 13 | } 14 | .fade-enter, 15 | .fade-leave-to { 16 | opacity: 0 17 | } 18 | -------------------------------------------------------------------------------- /resources/views/errors/layout.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Illuminate/Foundation/Exceptions/views --}} 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | @yield('title') 10 | 11 | 12 | 13 | 14 | 15 | 48 | 49 | 50 |
51 |
52 |
53 | @yield('message') 54 |
55 |
56 |
57 | 58 | 59 | -------------------------------------------------------------------------------- /resources/views/oauth/callback.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{ config('app.name') }} 5 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /resources/views/oauth/emailTaken.blade.php: -------------------------------------------------------------------------------- 1 | @extends('errors.layout') 2 | 3 | @section('title', 'Login Error') 4 | 5 | @section('message', 'Email already taken.') 6 | -------------------------------------------------------------------------------- /resources/views/spa.blade.php: -------------------------------------------------------------------------------- 1 | @php 2 | $config = [ 3 | 'appName' => config('app.name'), 4 | 'locale' => $locale = app()->getLocale(), 5 | 'locales' => config('app.locales'), 6 | 'githubAuth' => config('services.github.client_id'), 7 | ]; 8 | $appJs = mix('dist/js/app.js'); 9 | $appCss = mix('dist/css/app.css'); 10 | @endphp 11 | 12 | 13 | 14 | 15 | 16 | 17 | {{ config('app.name') }} 18 | 19 | 20 | 21 | 22 |
23 | 24 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | 'auth:api'], function () { 26 | Route::post('logout', [LoginController::class, 'logout']); 27 | 28 | Route::get('user', [UserController::class, 'current']); 29 | 30 | Route::patch('settings/profile', [ProfileController::class, 'update']); 31 | Route::patch('settings/password', [PasswordController::class, 'update']); 32 | }); 33 | 34 | Route::group(['middleware' => 'guest:api'], function () { 35 | Route::post('login', [LoginController::class, 'login']); 36 | Route::post('register', [RegisterController::class, 'register']); 37 | 38 | Route::post('password/email', [ForgotPasswordController::class, 'sendResetLinkEmail']); 39 | Route::post('password/reset', [ResetPasswordController::class, 'reset']); 40 | 41 | Route::post('email/verify/{user}', [VerificationController::class, 'verify'])->name('verification.verify'); 42 | Route::post('email/resend', [VerificationController::class, 'resend']); 43 | 44 | Route::post('oauth/{driver}', [OAuthController::class, 'redirect']); 45 | Route::get('oauth/{driver}/callback', [OAuthController::class, 'handleCallback'])->name('oauth.callback'); 46 | }); 47 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->purpose('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /routes/spa.php: -------------------------------------------------------------------------------- 1 | where('path', '(.*)'); 18 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | $uri = urldecode( 9 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 10 | ); 11 | 12 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 13 | // built-in PHP web server. This provides a convenient way to test a Laravel 14 | // application without having installed a "real" web server software here. 15 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 16 | return false; 17 | } 18 | 19 | require_once __DIR__.'/public/index.php'; 20 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | compiled.php 2 | config.php 3 | down 4 | events.scanned.php 5 | maintenance.php 6 | routes.php 7 | routes.scanned.php 8 | schedule-* 9 | services.json 10 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/Browser/ExampleTest.php: -------------------------------------------------------------------------------- 1 | browse(function (Browser $browser) { 18 | $browser->visit('/') 19 | ->pause(100) 20 | ->assertSee('Laravel'); 21 | }); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/Browser/LoginTest.php: -------------------------------------------------------------------------------- 1 | create(); 23 | 24 | $this->browse(function ($browser) use ($user) { 25 | $browser->visit(new Login) 26 | ->submit($user->email, 'password') 27 | ->assertPageIs(Home::class); 28 | }); 29 | } 30 | 31 | /** @test */ 32 | public function login_with_invalid_credentials() 33 | { 34 | $this->browse(function ($browser) { 35 | $browser->visit(new Login) 36 | ->submit('test@test.app', 'password') 37 | ->assertSee('These credentials do not match our records.'); 38 | }); 39 | } 40 | 41 | /** @test */ 42 | public function log_out_the_user() 43 | { 44 | $user = User::factory()->create(); 45 | 46 | $this->browse(function ($browser) use ($user) { 47 | $browser->visit(new Login) 48 | ->submit($user->email, 'password') 49 | ->on(new Home) 50 | ->clickLogout() 51 | ->assertPageIs(Login::class); 52 | }); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/Browser/Pages/Home.php: -------------------------------------------------------------------------------- 1 | waitForLocation($this->url())->assertPathIs($this->url()); 28 | } 29 | 30 | /** 31 | * Get the element shortcuts for the page. 32 | * 33 | * @return array 34 | */ 35 | public function elements() 36 | { 37 | return [ 38 | '@dropdown-toggle' => '.navbar-nav.ms-auto .dropdown-toggle', 39 | '@dropdown-menu' => '.dropdown-menu.show', 40 | ]; 41 | } 42 | 43 | /** 44 | * Click on the log out link. 45 | * 46 | * @param \Laravel\Dusk\Browser $browser 47 | * @return void 48 | */ 49 | public function clickLogout($browser) 50 | { 51 | $browser->click('@dropdown-toggle') 52 | ->waitFor('@dropdown-menu') 53 | ->waitForText('Logout') 54 | ->clickLink('Logout') 55 | ->pause(100); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /tests/Browser/Pages/HomePage.php: -------------------------------------------------------------------------------- 1 | '#selector', 39 | ]; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tests/Browser/Pages/Login.php: -------------------------------------------------------------------------------- 1 | type('email', $email) 28 | ->type('password', $password) 29 | ->press('Log In') 30 | ->pause(500); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/Browser/Pages/Page.php: -------------------------------------------------------------------------------- 1 | assertPathIs($this->url()); 19 | } 20 | 21 | /** 22 | * Get the global element shortcuts for the site. 23 | * 24 | * @return array 25 | */ 26 | public static function siteElements() 27 | { 28 | return [ 29 | '@element' => '#selector', 30 | ]; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/Browser/Pages/Register.php: -------------------------------------------------------------------------------- 1 | $value) { 27 | $browser->type($key, $value); 28 | } 29 | 30 | $browser->press('Register') 31 | ->pause(1000); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/Browser/RegisterTest.php: -------------------------------------------------------------------------------- 1 | browse(function ($browser) { 23 | $browser->visit(new Register) 24 | ->submit([ 25 | 'name' => 'Test User', 26 | 'email' => 'test@test.app', 27 | 'password' => 'password', 28 | 'password_confirmation' => 'password', 29 | ]) 30 | ->assertPageIs(Home::class); 31 | }); 32 | } 33 | 34 | /** @test */ 35 | public function can_not_register_with_the_same_twice() 36 | { 37 | $user = User::factory()->create(); 38 | 39 | $this->browse(function ($browser) use ($user) { 40 | $browser->visit(new Register) 41 | ->submit([ 42 | 'name' => 'Test User', 43 | 'email' => $user->email, 44 | 'password' => 'password', 45 | 'password_confirmation' => 'password', 46 | ]) 47 | ->assertSee('The email has already been taken.'); 48 | }); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /tests/Browser/WelcomeTest.php: -------------------------------------------------------------------------------- 1 | browse(function ($browser) { 13 | $browser->visit('/') 14 | ->waitFor('.title', 1) 15 | ->assertSee('Laravel'); 16 | }); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/Browser/console/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/Browser/screenshots/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/Browser/source/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/DuskTestCase.php: -------------------------------------------------------------------------------- 1 | waitForLocation($page->url())->assertPathIs($page->url()); 19 | }); 20 | 21 | abstract class DuskTestCase extends BaseTestCase 22 | { 23 | use DatabaseMigrations; 24 | use CreatesApplication; 25 | 26 | /** 27 | * Prepare for Dusk test execution. 28 | * 29 | * @beforeClass 30 | * @return void 31 | */ 32 | public static function prepare() 33 | { 34 | static::startChromeDriver(); 35 | } 36 | 37 | /** 38 | * Create the RemoteWebDriver instance. 39 | * 40 | * @return \Facebook\WebDriver\Remote\RemoteWebDriver 41 | */ 42 | protected function driver() 43 | { 44 | $options = (new ChromeOptions)->addArguments([ 45 | '--disable-gpu', 46 | '--headless', 47 | '--window-size=1920,1080', 48 | ]); 49 | 50 | return RemoteWebDriver::create( 51 | 'http://localhost:9515', DesiredCapabilities::chrome()->setCapability( 52 | ChromeOptions::CAPABILITY, $options 53 | ) 54 | ); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /tests/Feature/LocaleTest.php: -------------------------------------------------------------------------------- 1 | withHeaders(['Accept-Language' => 'zh-CN']) 13 | ->postJson('/api/login'); 14 | 15 | $this->assertEquals('zh-CN', $this->app->getLocale()); 16 | } 17 | 18 | /** @test */ 19 | public function set_locale_from_header_short() 20 | { 21 | $this->withHeaders(['Accept-Language' => 'en-US']) 22 | ->postJson('/api/login'); 23 | 24 | $this->assertEquals('en', $this->app->getLocale()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/Feature/LoginTest.php: -------------------------------------------------------------------------------- 1 | create(); 14 | 15 | $this->postJson('/api/login', [ 16 | 'email' => $user->email, 17 | 'password' => 'password', 18 | ]) 19 | ->assertSuccessful() 20 | ->assertJsonStructure(['token', 'expires_in']) 21 | ->assertJson(['token_type' => 'bearer']); 22 | } 23 | 24 | /** @test */ 25 | public function fetch_the_current_user() 26 | { 27 | $this->actingAs(User::factory()->create()) 28 | ->getJson('/api/user') 29 | ->assertSuccessful() 30 | ->assertJsonStructure(['id', 'name', 'email']); 31 | } 32 | 33 | /** @test */ 34 | public function log_out() 35 | { 36 | $token = $this->postJson('/api/login', [ 37 | 'email' => User::factory()->create()->email, 38 | 'password' => 'password', 39 | ])->json()['token']; 40 | 41 | $this->postJson("/api/logout?token=$token") 42 | ->assertSuccessful(); 43 | 44 | $this->getJson("/api/user?token=$token") 45 | ->assertStatus(401); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tests/Feature/OAuthTest.php: -------------------------------------------------------------------------------- 1 | getContent(), $text), "Expected text [{$text}] not found."); 22 | 23 | return $this; 24 | }); 25 | 26 | TestResponse::macro('assertTextMissing', function ($text) { 27 | PHPUnit::assertFalse(Str::contains($this->getContent(), $text), "Expected missing text [{$text}] found."); 28 | 29 | return $this; 30 | }); 31 | } 32 | 33 | /** @test */ 34 | public function redirect_to_provider() 35 | { 36 | $this->mockSocialite('github'); 37 | 38 | $this->postJson('/api/oauth/github') 39 | ->assertSuccessful() 40 | ->assertJson(['url' => 'https://url-to-provider']); 41 | } 42 | 43 | /** @test */ 44 | public function create_user_and_return_token() 45 | { 46 | $this->mockSocialite('github', [ 47 | 'id' => '123', 48 | 'name' => 'Test User', 49 | 'email' => 'test@example.com', 50 | 'token' => 'access-token', 51 | 'refreshToken' => 'refresh-token', 52 | ]); 53 | 54 | $this->withoutExceptionHandling(); 55 | 56 | $this->get('/api/oauth/github/callback') 57 | ->assertText('token') 58 | ->assertSuccessful(); 59 | 60 | $this->assertDatabaseHas('users', [ 61 | 'name' => 'Test User', 62 | 'email' => 'test@example.com', 63 | ]); 64 | 65 | $this->assertDatabaseHas('oauth_providers', [ 66 | 'user_id' => User::first()->id, 67 | 'provider' => 'github', 68 | 'provider_user_id' => '123', 69 | 'access_token' => 'access-token', 70 | 'refresh_token' => 'refresh-token', 71 | ]); 72 | } 73 | 74 | /** @test */ 75 | public function update_user_and_return_token() 76 | { 77 | $user = User::factory()->create(['email' => 'test@example.com']); 78 | $user->oauthProviders()->create([ 79 | 'provider' => 'github', 80 | 'provider_user_id' => '123', 81 | ]); 82 | 83 | $this->mockSocialite('github', [ 84 | 'id' => '123', 85 | 'email' => 'test@example.com', 86 | 'token' => 'updated-access-token', 87 | 'refreshToken' => 'updated-refresh-token', 88 | ]); 89 | 90 | $this->get('/api/oauth/github/callback') 91 | ->assertText('token') 92 | ->assertSuccessful(); 93 | 94 | $this->assertDatabaseHas('oauth_providers', [ 95 | 'user_id' => $user->id, 96 | 'access_token' => 'updated-access-token', 97 | 'refresh_token' => 'updated-refresh-token', 98 | ]); 99 | } 100 | 101 | /** @test */ 102 | public function can_not_create_user_if_email_is_taken() 103 | { 104 | User::factory()->create(['email' => 'test@example.com']); 105 | 106 | $this->mockSocialite('github', ['email' => 'test@example.com']); 107 | 108 | $this->get('/api/oauth/github/callback') 109 | ->assertText('Email already taken.') 110 | ->assertTextMissing('token') 111 | ->assertStatus(400); 112 | } 113 | 114 | protected function mockSocialite($provider, $user = null) 115 | { 116 | $mock = Socialite::shouldReceive('stateless') 117 | ->andReturn(m::self()) 118 | ->shouldReceive('driver') 119 | ->with($provider) 120 | ->andReturn(m::self()); 121 | 122 | if ($user) { 123 | $mock->shouldReceive('user') 124 | ->andReturn((new SocialiteUser)->setRaw($user)->map($user)); 125 | } else { 126 | $mock->shouldReceive('redirect') 127 | ->andReturn(redirect('https://url-to-provider')); 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /tests/Feature/RegisterTest.php: -------------------------------------------------------------------------------- 1 | postJson('/api/register', [ 14 | 'name' => 'Test User', 15 | 'email' => 'test@test.app', 16 | 'password' => 'secret', 17 | 'password_confirmation' => 'secret', 18 | ]) 19 | ->assertSuccessful() 20 | ->assertJsonStructure(['id', 'name', 'email']); 21 | } 22 | 23 | /** @test */ 24 | public function can_not_register_with_existing_email() 25 | { 26 | User::factory()->create(['email' => 'test@test.app']); 27 | 28 | $this->postJson('/api/register', [ 29 | 'name' => 'Test User', 30 | 'email' => 'test@test.app', 31 | 'password' => 'secret', 32 | 'password_confirmation' => 'secret', 33 | ]) 34 | ->assertStatus(422) 35 | ->assertJsonValidationErrors(['email']); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/Feature/SettingsTest.php: -------------------------------------------------------------------------------- 1 | actingAs($user = User::factory()->create()) 15 | ->patchJson('/api/settings/profile', [ 16 | 'name' => 'Test User', 17 | 'email' => 'test@test.app', 18 | ]) 19 | ->assertSuccessful() 20 | ->assertJsonStructure(['id', 'name', 'email']); 21 | 22 | $this->assertDatabaseHas('users', [ 23 | 'id' => $user->id, 24 | 'name' => 'Test User', 25 | 'email' => 'test@test.app', 26 | ]); 27 | } 28 | 29 | /** @test */ 30 | public function update_password() 31 | { 32 | $this->actingAs($user = User::factory()->create()) 33 | ->patchJson('/api/settings/password', [ 34 | 'password' => 'updated', 35 | 'password_confirmation' => 'updated', 36 | ]) 37 | ->assertSuccessful(); 38 | 39 | $this->assertTrue(Hash::check('updated', $user->password)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tests/Feature/VerificationTest.php: -------------------------------------------------------------------------------- 1 | create(['email_verified_at' => null]); 19 | $url = URL::temporarySignedRoute('verification.verify', now()->addMinutes(60), ['user' => $user->id]); 20 | 21 | Event::fake(); 22 | 23 | $this->postJson($url) 24 | ->assertSuccessful() 25 | ->assertJsonFragment(['status' => 'Your email has been verified!']); 26 | 27 | Event::assertDispatched(Verified::class, function (Verified $e) use ($user) { 28 | return $e->user->is($user); 29 | }); 30 | } 31 | 32 | /** @test */ 33 | public function can_not_verify_if_already_verified() 34 | { 35 | $user = User::factory()->create(); 36 | $url = URL::temporarySignedRoute('verification.verify', now()->addMinutes(60), ['user' => $user->id]); 37 | 38 | $this->postJson($url) 39 | ->assertStatus(400) 40 | ->assertJsonFragment(['status' => 'The email is already verified.']); 41 | } 42 | 43 | /** @test */ 44 | public function can_not_verify_if_url_has_invalid_signature() 45 | { 46 | $user = User::factory()->create(['email_verified_at' => null]); 47 | 48 | $this->postJson("/api/email/verify/{$user->id}") 49 | ->assertStatus(400) 50 | ->assertJsonFragment(['status' => 'The verification link is invalid.']); 51 | } 52 | 53 | /** @test */ 54 | public function resend_verification_notification() 55 | { 56 | $user = User::factory()->create(['email_verified_at' => null]); 57 | 58 | Notification::fake(); 59 | 60 | $this->postJson('/api/email/resend', ['email' => $user->email]) 61 | ->assertSuccessful(); 62 | 63 | Notification::assertSentTo($user, VerifyEmail::class); 64 | } 65 | 66 | /** @test */ 67 | public function can_not_resend_verification_notification_if_email_does_not_exist() 68 | { 69 | $this->postJson('/api/email/resend', ['email' => 'foo@bar.com']) 70 | ->assertStatus(422) 71 | ->assertJsonFragment(['errors' => ['email' => ['We can\'t find a user with that e-mail address.']]]); 72 | } 73 | 74 | /** @test */ 75 | public function can_not_resend_verification_notification_if_email_already_verified() 76 | { 77 | $user = User::factory()->create(); 78 | 79 | Notification::fake(); 80 | 81 | $this->postJson('/api/email/resend', ['email' => $user->email]) 82 | ->assertStatus(422) 83 | ->assertJsonFragment(['errors' => ['email' => ['The email is already verified.']]]); 84 | 85 | Notification::assertNotSentTo($user, VerifyEmail::class); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | const { join, resolve } = require('path') 2 | const { copySync, removeSync } = require('fs-extra') 3 | const mix = require('laravel-mix') 4 | require('laravel-mix-versionhash') 5 | // const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') 6 | 7 | mix 8 | .js('resources/js/app.js', 'public/dist/js').vue({ 9 | extractStyles: true 10 | }) 11 | .sass('resources/sass/app.scss', 'public/dist/css') 12 | 13 | .disableNotifications() 14 | 15 | if (mix.inProduction()) { 16 | mix 17 | // .extract() // Disabled until resolved: https://github.com/JeffreyWay/laravel-mix/issues/1889 18 | // .version() // Use `laravel-mix-versionhash` for the generating correct Laravel Mix manifest file. 19 | .versionHash() 20 | } else { 21 | mix.sourceMaps() 22 | } 23 | 24 | mix.webpackConfig({ 25 | plugins: [ 26 | // new BundleAnalyzerPlugin() 27 | ], 28 | resolve: { 29 | extensions: ['.js', '.json', '.vue'], 30 | alias: { 31 | '~': join(__dirname, './resources/js') 32 | } 33 | }, 34 | output: { 35 | chunkFilename: 'dist/js/[chunkhash].js', 36 | path: resolve(__dirname, mix.inProduction() ? './public/build' : './public') 37 | } 38 | }) 39 | 40 | mix.then(() => { 41 | if (mix.inProduction()) { 42 | process.nextTick(() => publishAseets()) 43 | } 44 | }) 45 | 46 | function publishAseets () { 47 | const publicDir = resolve(__dirname, './public') 48 | 49 | removeSync(join(publicDir, 'dist')) 50 | copySync(join(publicDir, 'build', 'dist'), join(publicDir, 'dist')) 51 | removeSync(join(publicDir, 'build')) 52 | } 53 | --------------------------------------------------------------------------------