From 2873f196ea2cdb52d6d742e09d27d59b81564054 Mon Sep 17 00:00:00 2001 From: Franck DAKIA Date: Sat, 11 Apr 2020 19:19:20 +0100 Subject: [PATCH] feat(auth): update auth configuration --- .editorconfig | 22 ++--- .env.example.json | 100 ++++++++++----------- .gitignore | 24 ++--- .travis.yml | 76 ++++++++-------- LICENSE | 42 ++++----- app/Controller/WelcomeController.php | 5 +- app/Kernel.php | 1 + app/Middleware/Guest.php | 2 +- bow | 110 +++++++++++------------ composer.json | 105 +++++++++++----------- config/auth.php | 16 +++- frontend/js/Example.jsx | 32 +++---- frontend/js/Example.vue | 18 ++-- frontend/js/app.js | 56 ++++++------ frontend/lang/en/lexique.php | 50 +++++------ frontend/lang/en/welcome.php | 10 +-- frontend/lang/fr/lexique.php | 50 +++++------ frontend/lang/fr/welcome.php | 10 +-- frontend/sass/_variables.scss | 6 +- frontend/sass/app.scss | 18 ++-- frontend/templates/errors/404.tintin.php | 26 +++--- frontend/templates/errors/500.tintin.php | 26 +++--- frontend/templates/layout.tintin.php | 70 +++++++-------- frontend/templates/welcome.tintin.php | 28 +++--- package.json | 66 +++++++------- phpunit.xml | 12 +-- public/.htaccess | 48 +++++----- public/index.php | 66 +++++++------- public/robots.txt | 4 +- readme.md | 78 ++++++++-------- routes/app.php | 13 +-- seeders/users_seeder.php | 2 +- tests/.gitkeep | 2 +- tests/Model/UserTest.php | 2 +- var/cache/.gitignore | 4 +- var/logs/.gitignore | 4 +- var/session/.gitignore | 4 +- var/storage/.gitignore | 4 +- var/view/.gitignore | 4 +- webpack.mix.js | 8 +- 40 files changed, 612 insertions(+), 612 deletions(-) diff --git a/.editorconfig b/.editorconfig index f264cf21..2508fbd3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,11 +1,11 @@ -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 4 -end_of_line = lf -insert_final_newline = true - -[*.{js,jsx,vue,vuex,scss,css,ts,tsx}] -indent_size = 2 +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +end_of_line = lf +insert_final_newline = true + +[*.{js,jsx,vue,vuex,scss,css,ts,tsx}] +indent_size = 2 diff --git a/.env.example.json b/.env.example.json index 66f8c6da..71c96d35 100644 --- a/.env.example.json +++ b/.env.example.json @@ -1,50 +1,50 @@ -{ - "APP_ENV": "development", - "APP_URL": "http://localhost:8000", - - "DB_DEFAULT": "mysql", - - "MYSQL_HOSTNAME": "127.0.0.1", - "MYSQL_USERNAME": "root", - "MYSQL_PASSWORD": "secret", - "MYSQL_DBNAME": "bowapp", - "MYSQL_CHARSET": "utf8mb4", - "MYSQL_COLLATE": "utf8mb4_unicode_ci", - "MYSQL_ENGINE": "InnoDB", - "MYSQL_PORT": 3306, - "MYSQL_SOCKET": "", - "MYSQL_PREFIX": "", - - "S3_KEY": "", - "S3_SECRET": "", - "S3_REGION": "", - "S3_BUCKET": "", - - "FTP_HOSTNAME": "localhost", - "FTP_PASSWORD": "password", - "FTP_USERNAME": "username", - "FTP_PORT": 21, - "FTP_STARTROOT": "", - "FTP_TLS": false, - "FTP_TIMEOUT": 50, - - "MAIL_DRIVER": "smtp", - - "SMTP_HOSTNAME": "localhost", - "SMTP_USERNAME": "username@localhost", - "SMTP_PASSWORD": "password", - "SMTP_PORT": 25, - "SMTP_TLS": false, - "SMTP_SSL": false, - "SMTP_TIMEOUT": 50, - - "SESSION_NAME": "BOW", - "SESSION_LIFE": 10800, - "SESSION_PATH": "/", - "SESSION_DOMAIN": null, - "SESSION_SECURE": false, - "SESSION_HTTPONLY": true, - - "CONTACT_EMAIL": "username@localhost", - "CONTACT_NAME": "username" -} +{ + "APP_ENV": "development", + "APP_URL": "http://localhost:8000", + + "DB_DEFAULT": "mysql", + + "MYSQL_HOSTNAME": "127.0.0.1", + "MYSQL_USERNAME": "root", + "MYSQL_PASSWORD": "secret", + "MYSQL_DBNAME": "bowapp", + "MYSQL_CHARSET": "utf8mb4", + "MYSQL_COLLATE": "utf8mb4_unicode_ci", + "MYSQL_ENGINE": "InnoDB", + "MYSQL_PORT": 3306, + "MYSQL_SOCKET": "", + "MYSQL_PREFIX": "", + + "S3_KEY": "", + "S3_SECRET": "", + "S3_REGION": "", + "S3_BUCKET": "", + + "FTP_HOSTNAME": "localhost", + "FTP_PASSWORD": "password", + "FTP_USERNAME": "username", + "FTP_PORT": 21, + "FTP_STARTROOT": "", + "FTP_TLS": false, + "FTP_TIMEOUT": 50, + + "MAIL_DRIVER": "smtp", + + "SMTP_HOSTNAME": "localhost", + "SMTP_USERNAME": "username@localhost", + "SMTP_PASSWORD": "password", + "SMTP_PORT": 25, + "SMTP_TLS": false, + "SMTP_SSL": false, + "SMTP_TIMEOUT": 50, + + "SESSION_NAME": "BOW", + "SESSION_LIFE": 10800, + "SESSION_PATH": "/", + "SESSION_DOMAIN": null, + "SESSION_SECURE": false, + "SESSION_HTTPONLY": true, + + "CONTACT_EMAIL": "username@localhost", + "CONTACT_NAME": "username" +} diff --git a/.gitignore b/.gitignore index 2847a6f1..64e79540 100755 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,12 @@ -.idea/ -!.gitignore -composer.lock -node_modules -vendor/ -package-lock.json -!.gitkeep -!public/**/.gitkeep -!var/**/.gitkeep -.env.json -config/.key -mix-manifest.json +.idea/ +!.gitignore +composer.lock +node_modules +vendor/ +package-lock.json +!.gitkeep +!public/**/.gitkeep +!var/**/.gitkeep +.env.json +config/.key +mix-manifest.json diff --git a/.travis.yml b/.travis.yml index 01b17871..3773f03e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,38 +1,38 @@ -language: php -dist: trusty - -branches: - only: - - 4.0 - - master - -services: - - mysql - -cache: - directories: - - $HOME/.composer/cache - -php: - - 7.1 - -env: - - DB_USER=travis - -before_script: - - mysql -u root -e 'CREATE DATABASE IF NOT EXISTS test;' - -install: - - composer install --prefer-dist - - composer require twig/twig - - php -r 'file_exists(".env.json") || copy(".env.example.json", ".env.json");' - - php bow run:server --port=5000 & - - sleep 5 - -matrix: - allow_failures: - - php: nightly - fast_finish: true - -script: - - ./vendor/bin/phpunit +language: php +dist: trusty + +branches: + only: + - 4.0 + - master + +services: + - mysql + +cache: + directories: + - $HOME/.composer/cache + +php: + - 7.1 + +env: + - DB_USER=travis + +before_script: + - mysql -u root -e 'CREATE DATABASE IF NOT EXISTS test;' + +install: + - composer install --prefer-dist + - composer require twig/twig + - php -r 'file_exists(".env.json") || copy(".env.example.json", ".env.json");' + - php bow run:server --port=5000 & + - sleep 5 + +matrix: + allow_failures: + - php: nightly + fast_finish: true + +script: + - ./vendor/bin/phpunit diff --git a/LICENSE b/LICENSE index 294a7d2b..e39e3636 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2016 Franck DAKIA - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE -OR OTHER DEALINGS IN THE SOFTWARE. +The MIT License (MIT) + +Copyright (c) 2016 Franck DAKIA + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/app/Controller/WelcomeController.php b/app/Controller/WelcomeController.php index 96cfa89d..c6e07721 100644 --- a/app/Controller/WelcomeController.php +++ b/app/Controller/WelcomeController.php @@ -11,11 +11,10 @@ class WelcomeController extends Controller * Show index * * @param Request $request - * @param string $name * @return string */ - public function __invoke(Request $request, string $name) + public function __invoke(Request $request) { - return sprintf('Hello, %s', $name); + return response()->render('welcome'); } } diff --git a/app/Kernel.php b/app/Kernel.php index 1b3c6dac..471e8327 100644 --- a/app/Kernel.php +++ b/app/Kernel.php @@ -63,6 +63,7 @@ public function configurations() /** * Add your Custom Settings here. */ + // \Policier\Bow\PolicierConfiguration::class, ]; } diff --git a/app/Middleware/Guest.php b/app/Middleware/Guest.php index 87c25106..272357ee 100644 --- a/app/Middleware/Guest.php +++ b/app/Middleware/Guest.php @@ -16,7 +16,7 @@ class Guest */ public function process(Request $request, callable $next) { - if (Auth::guest()) { + if (Auth::getInstance()->guest()) { return $next($request); } diff --git a/bow b/bow index 5af450eb..473c89de 100755 --- a/bow +++ b/bow @@ -1,55 +1,55 @@ -#!/usr/bin/env php -setNamespaces($kernel->namespaces()); - -/** - * Change preset destination - */ -$setting->setModelDirectory(__DIR__.'/app/Model'); -$setting->setValidationDirectory(__DIR__.'/app/Validation'); -$setting->setPackageDirectory(__DIR__.'/app/Configuration'); -$setting->setControllerDirectory(__DIR__.'/app/Controller'); -$setting->setMiddlewareDirectory(__DIR__.'/app/Middleware'); -$setting->setMigrationDirectory(__DIR__.'/migrations'); -$setting->setSeederDirectory(__DIR__.'/seeders'); -$setting->setComponentDirectory(__DIR__.'/frontend'); -$setting->setConfigDirectory(__DIR__.'/config'); -$setting->setPublicDirectory(__DIR__.'/public'); - -/** - * Defines the local server starter - */ -$setting->setServerFilename(__DIR__.'/server.php'); -$setting->setVarDirectory(__DIR__.'/var'); - -/** - * Create console instance - */ -$console = new \Bow\Console\Console($setting); - -/** - * Bind kernel to console - */ -$console->bind($kernel); - -/** - * Load the custom command application - */ -require __DIR__.'/routes/console.php'; - -/** - * Start console - */ -$console->run(); +#!/usr/bin/env php +setNamespaces($kernel->namespaces()); + +/** + * Change preset destination + */ +$setting->setModelDirectory(__DIR__.'/app/Model'); +$setting->setValidationDirectory(__DIR__.'/app/Validation'); +$setting->setPackageDirectory(__DIR__.'/app/Configuration'); +$setting->setControllerDirectory(__DIR__.'/app/Controller'); +$setting->setMiddlewareDirectory(__DIR__.'/app/Middleware'); +$setting->setMigrationDirectory(__DIR__.'/migrations'); +$setting->setSeederDirectory(__DIR__.'/seeders'); +$setting->setComponentDirectory(__DIR__.'/frontend'); +$setting->setConfigDirectory(__DIR__.'/config'); +$setting->setPublicDirectory(__DIR__.'/public'); + +/** + * Defines the local server starter + */ +$setting->setServerFilename(__DIR__.'/server.php'); +$setting->setVarDirectory(__DIR__.'/var'); + +/** + * Create console instance + */ +$console = new \Bow\Console\Console($setting); + +/** + * Bind kernel to console + */ +$console->bind($kernel); + +/** + * Load the custom command application + */ +require __DIR__.'/routes/console.php'; + +/** + * Start console + */ +$console->run(); diff --git a/composer.json b/composer.json index fbfaf17b..141f8dbe 100644 --- a/composer.json +++ b/composer.json @@ -1,52 +1,53 @@ -{ - "name": "bowphp/app", - "description": "The bow PHP Framework", - "keywords": ["framework", "bow", "php", "php-framework"], - "type": "project", - "license": "MIT", - "support": { - "issues": "https://github.com/bowphp/app/issues", - "source": "https://github.com/bowphp/app" - }, - "require": { - "php": ">=7.1", - "bowphp/framework": "4.1.*" - }, - "require-dev": { - "phpunit/phpunit": "^7", - "monolog/monolog": "^1.22", - "squizlabs/php_codesniffer": "3.*" - }, - "authors": [ - { - "name": "Franck DAKIA", - "email": "dakiafranck@gmail.com", - "role": "Lead Developer" - } - ], - "autoload": { - "psr-4": { - "App\\": "app/" - }, - "files": [ - "config/helper.php" - ] - }, - "scripts": { - "post-root-package-install":[ - "@php -r \"file_exists('.env.json') || copy('.env.example.json', '.env.json');\"" - ], - "post-create-project-cmd": [ - "@php bow generate:key" - ] - }, - "config": { - "preferred-install": "dist", - "sort-packages": true, - "optimize-autoloader": true - }, - "suggest": { - "twig/twig": "For the use of template engine 'Twig'", - "papac/bow-blade": "For the use of template engine 'Blade'" - } -} +{ + "name": "bowphp/app", + "description": "The bow PHP Framework", + "keywords": ["framework", "bow", "php", "php-framework"], + "type": "project", + "license": "MIT", + "support": { + "issues": "https://github.com/bowphp/app/issues", + "source": "https://github.com/bowphp/app" + }, + "require": { + "php": ">=7.1", + "bowphp/framework": "4.1.*", + "bowphp/policier": "^2.0" + }, + "require-dev": { + "phpunit/phpunit": "^7", + "monolog/monolog": "^1.22", + "squizlabs/php_codesniffer": "3.*" + }, + "authors": [ + { + "name": "Franck DAKIA", + "email": "dakiafranck@gmail.com", + "role": "Lead Developer" + } + ], + "autoload": { + "psr-4": { + "App\\": "app/" + }, + "files": [ + "config/helper.php" + ] + }, + "scripts": { + "post-root-package-install":[ + "@php -r \"file_exists('.env.json') || copy('.env.example.json', '.env.json');\"" + ], + "post-create-project-cmd": [ + "@php bow generate:key" + ] + }, + "config": { + "preferred-install": "dist", + "sort-packages": true, + "optimize-autoloader": true + }, + "suggest": { + "twig/twig": "For the use of template engine 'Twig'", + "papac/bow-blade": "For the use of template engine 'Blade'" + } +} diff --git a/config/auth.php b/config/auth.php index 0d1be874..0a157ff6 100644 --- a/config/auth.php +++ b/config/auth.php @@ -10,15 +10,23 @@ * Default authentication branch */ "web" => [ - "type" => "model", - 'model' => App\Model\User::class + "type" => "jwt", + 'model' => App\Model\User::class, + 'credentials' => [ + 'username' => 'email', + 'password' => 'password' + ] ], /** * Other authentication branch */ "admin" => [ - 'type' => "model", - "model" => App\Model\User::class + 'type' => "session", + "model" => App\Model\User::class, + 'credentials' => [ + 'username' => 'email', + 'password' => 'password' + ] ] ]; diff --git a/frontend/js/Example.jsx b/frontend/js/Example.jsx index 2c39c911..1c109a36 100644 --- a/frontend/js/Example.jsx +++ b/frontend/js/Example.jsx @@ -1,16 +1,16 @@ -import React, { Component } from 'react'; -import ReactDOM from 'react-dom'; - -export default class Example extends Component { - render() { - return ( -
- I'm an example React Component. -
- ); - } -} - -if (document.getElementById('main')) { - ReactDOM.render(, document.getElementById('main')); -} +import React, { Component } from 'react'; +import ReactDOM from 'react-dom'; + +export default class Example extends Component { + render() { + return ( +
+ I'm an example React Component. +
+ ); + } +} + +if (document.getElementById('main')) { + ReactDOM.render(, document.getElementById('main')); +} diff --git a/frontend/js/Example.vue b/frontend/js/Example.vue index 475ca77f..35f2efd5 100644 --- a/frontend/js/Example.vue +++ b/frontend/js/Example.vue @@ -1,9 +1,9 @@ - - - + + + diff --git a/frontend/js/app.js b/frontend/js/app.js index d4928649..898a7abb 100644 --- a/frontend/js/app.js +++ b/frontend/js/app.js @@ -1,28 +1,28 @@ -import jQuery from "jquery" -/** - * // Loader Example Vue component - * import Vue from "vue" - * import Example from "./Example.vue" - * - * Vue.component('example', Example); - * - * new Vue({ - * el: "#main" - * }); - */ - -/** - * Import JQuery - */ -window.jQuery = window.$ = jQuery; - -$.ajaxSetup({ - headers: { - 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') - } -}); - -/** - * Loader Example React component - */ -require('./Example.jsx'); +import jQuery from "jquery" +/** + * // Loader Example Vue component + * import Vue from "vue" + * import Example from "./Example.vue" + * + * Vue.component('example', Example); + * + * new Vue({ + * el: "#main" + * }); + */ + +/** + * Import JQuery + */ +window.jQuery = window.$ = jQuery; + +$.ajaxSetup({ + headers: { + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') + } +}); + +/** + * Loader Example React component + */ +require('./Example.jsx'); diff --git a/frontend/lang/en/lexique.php b/frontend/lang/en/lexique.php index 0d48dc10..580f072f 100644 --- a/frontend/lang/en/lexique.php +++ b/frontend/lang/en/lexique.php @@ -1,25 +1,25 @@ - 'The field :attribute must be an email.', - 'required' => 'The field :attribute is required.', - 'empty' => 'The field :attribute is missing in the fields to be validated.', - 'min' => 'The field :attribute must be at least :length characters long.', - 'max' => 'The field :attribute must not exceed :length characters.', - 'same' => 'The field :attribute must be the same as :value.', - 'number' => 'The field :attribute must be a number.', - 'int' => 'The field :attribute must be an integer.', - 'float' => 'The field :attribute must be a decimal.', - 'alphanum' => 'Only alphanumeric characters are allowed for field :attribute.', - 'in' => 'The field :attribute must be one of the following :value.', - 'size' => 'The field :attribute must be :length characters long.', - 'lower' => 'Only lowercase letters are allowed for field :attribute.', - 'upper' => 'Only uppercase letters are allowed for field :attribute.', - 'alpha' => 'Only alphabetic characters are allowed for field :attribute.', - 'exists' => 'The field :attribute does not exists.', - 'not_exists' => 'The field :attribute already exists.', - 'unique' => 'The field :attribute must be unique.', - 'date' => 'The field :attribute must use the format: yyyy-mm-dd', - 'datetime' => 'The field :attribute must use the format: yyyy-mm-dd hh:mm:ss', - 'regex' => 'The field :attribute does not match the pattern', -]; + 'The field :attribute must be an email.', + 'required' => 'The field :attribute is required.', + 'empty' => 'The field :attribute is missing in the fields to be validated.', + 'min' => 'The field :attribute must be at least :length characters long.', + 'max' => 'The field :attribute must not exceed :length characters.', + 'same' => 'The field :attribute must be the same as :value.', + 'number' => 'The field :attribute must be a number.', + 'int' => 'The field :attribute must be an integer.', + 'float' => 'The field :attribute must be a decimal.', + 'alphanum' => 'Only alphanumeric characters are allowed for field :attribute.', + 'in' => 'The field :attribute must be one of the following :value.', + 'size' => 'The field :attribute must be :length characters long.', + 'lower' => 'Only lowercase letters are allowed for field :attribute.', + 'upper' => 'Only uppercase letters are allowed for field :attribute.', + 'alpha' => 'Only alphabetic characters are allowed for field :attribute.', + 'exists' => 'The field :attribute does not exists.', + 'not_exists' => 'The field :attribute already exists.', + 'unique' => 'The field :attribute must be unique.', + 'date' => 'The field :attribute must use the format: yyyy-mm-dd', + 'datetime' => 'The field :attribute must use the format: yyyy-mm-dd hh:mm:ss', + 'regex' => 'The field :attribute does not match the pattern', +]; diff --git a/frontend/lang/en/welcome.php b/frontend/lang/en/welcome.php index 29e237f0..31ac55a4 100644 --- a/frontend/lang/en/welcome.php +++ b/frontend/lang/en/welcome.php @@ -1,5 +1,5 @@ - 'Bow Framework, simplify your Web development' -]; + 'Bow Framework, simplify your Web development' +]; diff --git a/frontend/lang/fr/lexique.php b/frontend/lang/fr/lexique.php index 20c0eaa1..8654605e 100644 --- a/frontend/lang/fr/lexique.php +++ b/frontend/lang/fr/lexique.php @@ -1,25 +1,25 @@ - "Le champ :attribute doit ≖tre un email.", - 'required' => "Le champ :attribute est requis.", - 'empty' => "Le champ :attribute n'est pas défini dans les données à valider.", - 'min' => "Le champ :attribute doit avoir un contenu minimal de :length.", - 'max' => "Le champ :attribute doit avoir un contenu maximal de :length.", - 'same' => "Le champ :attribute doit avoir un contenu égal à :value.", - 'number' => "Le champ :attribute doit avoir un contenu en numérique.", - 'int' => "Le champ :attribute doit avoir un contenu de type entier.", - 'float' => "Le champ :attribute doit avoir un contenu de type réel.", - 'alphanum' => "Le champ :attribute doit avoir un contenu en alphanumérique.", - 'in' => "Le champ :attribute doit avoir un contenu une valeur dans :value.", - 'size' => "Le champ :attribute doit avoir un contenu de :length caractère(s).", - 'lower' => "Le champ :attribute doit avoir un contenu en miniscule.", - 'upper' => "Le champ :attribute doit avoir un contenu en majiscule.", - 'alpha' => "Le champ :attribute doit avoir un contenu en alphabetique.", - 'exists' => "le champe :attribute n'existe pas.", - 'not_exists' => "le champ :attribute existe.", - 'unique' => "le champ :attribute n'est pas unique.", - 'date' => "Le champ :attribute n'est pas une date au format yyyy-mm-dd", - 'datetime' => "Le champ :attribute n'est pas une date au format yyyy-mm-dd hh:mm:ss", - 'regex' => "Le champ :attribute n'est pas valide", -]; + "Le champ :attribute doit ≖tre un email.", + 'required' => "Le champ :attribute est requis.", + 'empty' => "Le champ :attribute n'est pas défini dans les données à valider.", + 'min' => "Le champ :attribute doit avoir un contenu minimal de :length.", + 'max' => "Le champ :attribute doit avoir un contenu maximal de :length.", + 'same' => "Le champ :attribute doit avoir un contenu égal à :value.", + 'number' => "Le champ :attribute doit avoir un contenu en numérique.", + 'int' => "Le champ :attribute doit avoir un contenu de type entier.", + 'float' => "Le champ :attribute doit avoir un contenu de type réel.", + 'alphanum' => "Le champ :attribute doit avoir un contenu en alphanumérique.", + 'in' => "Le champ :attribute doit avoir un contenu une valeur dans :value.", + 'size' => "Le champ :attribute doit avoir un contenu de :length caractère(s).", + 'lower' => "Le champ :attribute doit avoir un contenu en miniscule.", + 'upper' => "Le champ :attribute doit avoir un contenu en majiscule.", + 'alpha' => "Le champ :attribute doit avoir un contenu en alphabetique.", + 'exists' => "le champe :attribute n'existe pas.", + 'not_exists' => "le champ :attribute existe.", + 'unique' => "le champ :attribute n'est pas unique.", + 'date' => "Le champ :attribute n'est pas une date au format yyyy-mm-dd", + 'datetime' => "Le champ :attribute n'est pas une date au format yyyy-mm-dd hh:mm:ss", + 'regex' => "Le champ :attribute n'est pas valide", +]; diff --git a/frontend/lang/fr/welcome.php b/frontend/lang/fr/welcome.php index 1ee24486..22ade228 100644 --- a/frontend/lang/fr/welcome.php +++ b/frontend/lang/fr/welcome.php @@ -1,5 +1,5 @@ - 'bow framework, simplifiez votre Développement Web' -]; + 'bow framework, simplifiez votre Développement Web' +]; diff --git a/frontend/sass/_variables.scss b/frontend/sass/_variables.scss index 089c0393..b30edc8d 100644 --- a/frontend/sass/_variables.scss +++ b/frontend/sass/_variables.scss @@ -1,3 +1,3 @@ -$color: #bd362f; - -$font-family: 'Lato', 'console', monospace, serif, 'sans-serif'; +$color: #bd362f; + +$font-family: 'Lato', 'console', monospace, serif, 'sans-serif'; diff --git a/frontend/sass/app.scss b/frontend/sass/app.scss index 95ba64b0..e7f35b52 100644 --- a/frontend/sass/app.scss +++ b/frontend/sass/app.scss @@ -1,9 +1,9 @@ -@import "variables"; - -#main { - position: relative; - margin: 10% auto; - width: 550px; - text-align: center; - font-family: $font-family; -} +@import "variables"; + +#main { + position: relative; + margin: 10% auto; + width: 550px; + text-align: center; + font-family: $font-family; +} diff --git a/frontend/templates/errors/404.tintin.php b/frontend/templates/errors/404.tintin.php index 65bb55a2..584a0540 100644 --- a/frontend/templates/errors/404.tintin.php +++ b/frontend/templates/errors/404.tintin.php @@ -1,13 +1,13 @@ -#extends('layout') - -#block('title', '404 - Not Found') - -#block('content') -
-

404

-

- Not found page
- Back -

-
-#endblock +#extends('layout') + +#block('title', '404 - Not Found') + +#block('content') +
+

404

+

+ Not found page
+ Back +

+
+#endblock diff --git a/frontend/templates/errors/500.tintin.php b/frontend/templates/errors/500.tintin.php index a7ec6ce4..0294bde5 100644 --- a/frontend/templates/errors/500.tintin.php +++ b/frontend/templates/errors/500.tintin.php @@ -1,13 +1,13 @@ -#extends('layout') - -#block('title', '500 - Internal Server Error') - -#block('content') -
-

500

-

- {{ $exception->getMessage() }}
- Back -

-
-#endblock +#extends('layout') + +#block('title', '500 - Internal Server Error') + +#block('content') +
+

500

+

+ {{ $exception->getMessage() }}
+ Back +

+
+#endblock diff --git a/frontend/templates/layout.tintin.php b/frontend/templates/layout.tintin.php index d8120d10..0969a314 100644 --- a/frontend/templates/layout.tintin.php +++ b/frontend/templates/layout.tintin.php @@ -1,35 +1,35 @@ - - - - - - - - - #inject('title', 'It\'s Worked') - - - -
- #inject('content') -
- #inject('script') - - + + + + + + + + + #inject('title', 'It\'s Worked') + + + +
+ #inject('content') +
+ #inject('script') + + diff --git a/frontend/templates/welcome.tintin.php b/frontend/templates/welcome.tintin.php index 23075a90..b6a647e2 100644 --- a/frontend/templates/welcome.tintin.php +++ b/frontend/templates/welcome.tintin.php @@ -1,14 +1,14 @@ -#extends('layout') - -#block('title', 'It\'s Worked') - -#block('content') - -
- I'm a bow application, you can see my documentation. -
-#endblock - -#block('script') - {# #} -#endblock +#extends('layout') + +#block('title', 'It\'s Worked') + +#block('content') + +
+ I'm a bow application, you can see my documentation. +
+#endblock + +#block('script') + {# #} +#endblock diff --git a/package.json b/package.json index e6b1e506..5b98641f 100644 --- a/package.json +++ b/package.json @@ -1,33 +1,33 @@ -{ - "scripts": { - "dev": "npm run development", - "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", - "prod": "npm run production", - "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", - "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", - "hot": "cross-env NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", - "php-fix-sniffer": "./vendor/bin/phpcbf --standard=psr2 --tab-width=4 app tests config database", - "php-sniffer": "./vendor/bin/phpcs --standard=psr2 --tab-width=4 app tests config database" - }, - "dependencies": { - "axios": "^0.18", - "babel-loader": "^8.0.4", - "bootstrap": "^4.0.0", - "cross-env": "^5.1", - "css-loader": "^2.0.2", - "jquery": "^3.2", - "laravel-mix": "^4.0.7", - "lodash": "^4.17.5", - "popper.js": "^1.12", - "react": "^16.7.0", - "react-dom": "^16.7.0", - "resolve-url-loader": "^2.3.1", - "sass": "^1.15.2", - "sass-loader": "^7.1.0", - "vue": "^2.5.17" - }, - "devDependencies": { - "@babel/preset-react": "^7.0.0", - "vue-template-compiler": "^2.5.21" - } -} +{ + "scripts": { + "dev": "npm run development", + "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "prod": "npm run production", + "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "hot": "cross-env NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", + "format": "./vendor/bin/phpcbf --standard=psr2 --tab-width=4 app tests config migrations seeders routes", + "code-sniffer": "./vendor/bin/phpcs --standard=psr2 --tab-width=4 app tests config migrations seeders routes" + }, + "dependencies": { + "axios": "^0.18", + "babel-loader": "^8.0.4", + "bootstrap": "^4.0.0", + "cross-env": "^5.1", + "css-loader": "^2.0.2", + "jquery": "^3.2", + "laravel-mix": "^4.0.7", + "lodash": "^4.17.5", + "popper.js": "^1.12", + "react": "^16.7.0", + "react-dom": "^16.7.0", + "resolve-url-loader": "^2.3.1", + "sass": "^1.15.2", + "sass-loader": "^7.1.0", + "vue": "^2.5.17" + }, + "devDependencies": { + "@babel/preset-react": "^7.0.0", + "vue-template-compiler": "^2.5.21" + } +} diff --git a/phpunit.xml b/phpunit.xml index 047c9f68..13ee1585 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,6 +1,6 @@ - - - - tests/ - - + + + + tests/ + + diff --git a/public/.htaccess b/public/.htaccess index 01e7ba71..5033c596 100755 --- a/public/.htaccess +++ b/public/.htaccess @@ -1,24 +1,24 @@ -Options -indexes - - - - - Options -MultiViews - - - RewriteEngine On - - # Configuration pour les serveurs mutualisés - # RewriteCond %{REQUEST_FILENAME} !-d - # RewriteCond %{REQUEST_FILENAME} !-f - # RewriteRule ^(.*)\.(gif|png|js|css|jpg|jpeg|swf|tff|woff|eof|mp3|mp4) /public/$1.$2 [L,NC] - - # rédirige les URLs avec un slash à la fin, si ce n'est un dossier. - RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule ^(.*)/$ /$1 [L,R=301] - - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{REQUEST_FILENAME} !-f - - RewriteRule ^ index.php [L] - +Options -indexes + + + + + Options -MultiViews + + + RewriteEngine On + + # Configuration pour les serveurs mutualisés + # RewriteCond %{REQUEST_FILENAME} !-d + # RewriteCond %{REQUEST_FILENAME} !-f + # RewriteRule ^(.*)\.(gif|png|js|css|jpg|jpeg|swf|tff|woff|eof|mp3|mp4) /public/$1.$2 [L,NC] + + # rédirige les URLs avec un slash à la fin, si ce n'est un dossier. + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.*)/$ /$1 [L,R=301] + + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + + RewriteRule ^ index.php [L] + diff --git a/public/index.php b/public/index.php index 2a758b4e..4b110766 100644 --- a/public/index.php +++ b/public/index.php @@ -1,33 +1,33 @@ -bind($kernel); - -/** - * Load application routing - */ -require __DIR__ . "/../routes/app.php"; - -/** - * Send application response - */ -$app->send(); +bind($kernel); + +/** + * Load application routing + */ +require __DIR__ . "/../routes/app.php"; + +/** + * Send application response + */ +$app->send(); diff --git a/public/robots.txt b/public/robots.txt index ace1d76f..f3bab41d 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,2 +1,2 @@ -User-agent: * -Disallow: public/ +User-agent: * +Disallow: public/ diff --git a/readme.md b/readme.md index e12c8451..d3180235 100644 --- a/readme.md +++ b/readme.md @@ -1,40 +1,40 @@ - - -## Bow Framework - - - - - - -Bow is a PHP Framework, written by **[Franck DAKIA](http://github.com/papac)** and several other contributors. - -The goal is to allow beginners who want to work on a project a little bigger to get started, to understand the workings of **collaborative development**. And make this framework a reference in the PHP community around the world. - -**Do not hesitate to start now with the [documentation](https://bowphp.github.io).** - -## Prerequisites - -You must make sure the following items are installed on your machine. - -- PHP >= 7.1 -- OpenSSL PHP Extension -- PDO PHP Extension -- Mbstring PHP Extension -- XML PHP Extension -- JSON PHP Extension - -## Contributing - -Thank you for considering contributing to Bow Framework! The contribution guide is in the framework documentation. - -- [Franck DAKIA](https://github.com/papac) -- [Thank's collaborators](https://github.com/bowphp/app/graphs/contributors) - -## Contact - -[dakiafranck@gmail.com](mailto:dakiafranck@gmail.com) - [@franck_dakia](https://twitter.com/franck_dakia) - -**Please, if there is a bug on the project please contact me by email or leave me a message on the [slack](https://bowphp.slack.com). or [join us on slask](https://join.slack.com/t/bowphp/shared_invite/enQtNzMxOTQ0MTM2ODM5LTQ3MWQ3Mzc1NDFiNDYxMTAyNzBkNDJlMTgwNDJjM2QyMzA2YTk4NDYyN2NiMzM0YTZmNjU1YjBhNmJjZThiM2Q)** - + + +## Bow Framework + + + + + + +Bow is a PHP Framework, written by **[Franck DAKIA](http://github.com/papac)** and several other contributors. + +The goal is to allow beginners who want to work on a project a little bigger to get started, to understand the workings of **collaborative development**. And make this framework a reference in the PHP community around the world. + +**Do not hesitate to start now with the [documentation](https://bowphp.github.io).** + +## Prerequisites + +You must make sure the following items are installed on your machine. + +- PHP >= 7.1 +- OpenSSL PHP Extension +- PDO PHP Extension +- Mbstring PHP Extension +- XML PHP Extension +- JSON PHP Extension + +## Contributing + +Thank you for considering contributing to Bow Framework! The contribution guide is in the framework documentation. + +- [Franck DAKIA](https://github.com/papac) +- [Thank's collaborators](https://github.com/bowphp/app/graphs/contributors) + +## Contact + +[dakiafranck@gmail.com](mailto:dakiafranck@gmail.com) - [@franck_dakia](https://twitter.com/franck_dakia) + +**Please, if there is a bug on the project please contact me by email or leave me a message on the [slack](https://bowphp.slack.com). or [join us on slask](https://join.slack.com/t/bowphp/shared_invite/enQtNzMxOTQ0MTM2ODM5LTQ3MWQ3Mzc1NDFiNDYxMTAyNzBkNDJlMTgwNDJjM2QyMzA2YTk4NDYyN2NiMzM0YTZmNjU1YjBhNmJjZThiM2Q)** + Buy Me A Coffee \ No newline at end of file diff --git a/routes/app.php b/routes/app.php index 234cbe03..59f55d49 100644 --- a/routes/app.php +++ b/routes/app.php @@ -1,18 +1,9 @@ get('/', function () { - return response()->render('welcome'); -}); - -$app->get('/:name', 'WelcomeController'); +$app->get('/', 'WelcomeController')->middleware('auth'); +$app->get('/login', 'WelcomeController')->middleware('guest'); diff --git a/seeders/users_seeder.php b/seeders/users_seeder.php index 6c655fcd..bd97d67b 100644 --- a/seeders/users_seeder.php +++ b/seeders/users_seeder.php @@ -14,7 +14,7 @@ 'name' => $faker->name, 'description' => $faker->text, 'email' => $faker->email, - 'password' => $faker->password, + 'password' => '$2y$10$2iITokZq4x/HFQgvbNZNEuKtqv8o1Eh8y.1QxgtNBGQdzRcatKq7a', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s') ]; diff --git a/tests/.gitkeep b/tests/.gitkeep index 8b137891..d3f5a12f 100644 --- a/tests/.gitkeep +++ b/tests/.gitkeep @@ -1 +1 @@ - + diff --git a/tests/Model/UserTest.php b/tests/Model/UserTest.php index f21c980d..90fc242c 100644 --- a/tests/Model/UserTest.php +++ b/tests/Model/UserTest.php @@ -7,7 +7,7 @@ class UserTest extends TestCase { /** * The simple text - * + * * @return void */ public function testInstance() diff --git a/var/cache/.gitignore b/var/cache/.gitignore index d6b7ef32..005717ea 100644 --- a/var/cache/.gitignore +++ b/var/cache/.gitignore @@ -1,2 +1,2 @@ -* -!.gitignore +* +!.gitignore diff --git a/var/logs/.gitignore b/var/logs/.gitignore index d6b7ef32..005717ea 100644 --- a/var/logs/.gitignore +++ b/var/logs/.gitignore @@ -1,2 +1,2 @@ -* -!.gitignore +* +!.gitignore diff --git a/var/session/.gitignore b/var/session/.gitignore index d6b7ef32..005717ea 100644 --- a/var/session/.gitignore +++ b/var/session/.gitignore @@ -1,2 +1,2 @@ -* -!.gitignore +* +!.gitignore diff --git a/var/storage/.gitignore b/var/storage/.gitignore index d6b7ef32..005717ea 100755 --- a/var/storage/.gitignore +++ b/var/storage/.gitignore @@ -1,2 +1,2 @@ -* -!.gitignore +* +!.gitignore diff --git a/var/view/.gitignore b/var/view/.gitignore index d6b7ef32..005717ea 100644 --- a/var/view/.gitignore +++ b/var/view/.gitignore @@ -1,2 +1,2 @@ -* -!.gitignore +* +!.gitignore diff --git a/webpack.mix.js b/webpack.mix.js index 25f8d350..5101d67b 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -1,4 +1,4 @@ -let mix = require('laravel-mix'); - -mix.react('frontend/js/app.js', 'public/js') - .sass('frontend/sass/app.scss', 'public/css'); +let mix = require('laravel-mix'); + +mix.react('frontend/js/app.js', 'public/js') + .sass('frontend/sass/app.scss', 'public/css');