diff --git a/motorradig/.idea/motorradig.iml b/motorradig/.idea/motorradig.iml
index 324fc34..512bc56 100644
--- a/motorradig/.idea/motorradig.iml
+++ b/motorradig/.idea/motorradig.iml
@@ -25,10 +25,12 @@
+
+
@@ -79,8 +81,10 @@
+
+
@@ -89,6 +93,7 @@
+
diff --git a/motorradig/.idea/php.xml b/motorradig/.idea/php.xml
index 2232a4a..f54db4e 100644
--- a/motorradig/.idea/php.xml
+++ b/motorradig/.idea/php.xml
@@ -88,12 +88,17 @@
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/motorradig/.idea/workspace.xml b/motorradig/.idea/workspace.xml
index 633c0cb..1b5c4bd 100644
--- a/motorradig/.idea/workspace.xml
+++ b/motorradig/.idea/workspace.xml
@@ -2,15 +2,22 @@
-
-
+
+
+
+
+
+
-
-
+
+
+
+
+
-
-
+
+
@@ -124,6 +131,11 @@
+
+
+
+
+
@@ -220,7 +232,8 @@
-
+
+
@@ -252,9 +265,9 @@
-
+
-
+
\ No newline at end of file
diff --git a/motorradig/app/Http/Controllers/PageController.php b/motorradig/app/Http/Controllers/PageController.php
new file mode 100644
index 0000000..308b620
--- /dev/null
+++ b/motorradig/app/Http/Controllers/PageController.php
@@ -0,0 +1,53 @@
+all(), [
+ 'page' => 'required',
+ ]);
+ if ($v->fails()) {
+ return response()->json([
+ 'status' => 'error',
+ 'errors' => $v->errors()
+ ], 422);
+ }
+ $p = Pagecontents::where('page',$request->page)->first();
+
+ //Log::info("Returning Body");
+ //Log::info($p->body);
+ return response()->json(['body' => $p->body], 200);
+ }
+
+ public function save_page(Request $request) {
+ $v = Validator::make($request->all(), [
+ 'page' => 'required',
+ 'body' => 'required'
+ ]);
+
+ if ($v->fails()) {
+ return response()->json([
+ 'status' => 'error',
+ 'errors' => $v->errors()
+ ], 422);
+ }
+
+ $p = Pagecontents::where('page',$request->page)->first();
+ if ($p==null) {
+ $p = new Pagecontents();
+ }
+ $p->page = $request->page;
+ $p->body = $request->body;
+
+
+ $p->save();
+ }
+}
diff --git a/motorradig/app/Http/Middleware/Authenticate.php b/motorradig/app/Http/Middleware/Authenticate.php
index a4be5c5..9e648c1 100644
--- a/motorradig/app/Http/Middleware/Authenticate.php
+++ b/motorradig/app/Http/Middleware/Authenticate.php
@@ -3,6 +3,7 @@
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
+use Closure;
class Authenticate extends Middleware
{
@@ -18,4 +19,27 @@ class Authenticate extends Middleware
return route('login');
}
}
+
+ // Override handle method
+ public function handle($request, Closure $next, ...$guards)
+ {
+ if ($this->authenticate($request, $guards) === 'authentication_failed') {
+ return response()->json(['error'=>'Unauthorized'],400);
+ }
+ return $next($request);
+ }
+ // Override authentication method
+ protected function authenticate($request, array $guards)
+ {
+ if (empty($guards)) {
+ $guards = [null];
+ }
+ foreach ($guards as $guard) {
+ if ($this->auth->guard($guard)->check()) {
+ return $this->auth->shouldUse($guard);
+ }
+ }
+ return 'authentication_failed';
+ }
+
}
diff --git a/motorradig/app/Pagecontents.php b/motorradig/app/Pagecontents.php
new file mode 100644
index 0000000..b5a6f22
--- /dev/null
+++ b/motorradig/app/Pagecontents.php
@@ -0,0 +1,10 @@
+ 'datetime',
];
+
+ public function getJWTIdentifier() {
+ return $this->getKey();
+ }
+ public function getJWTCustomClaims() {
+ return [];
+ }
+
}
diff --git a/motorradig/composer.json b/motorradig/composer.json
index bfa54bd..c6277ce 100644
--- a/motorradig/composer.json
+++ b/motorradig/composer.json
@@ -12,7 +12,8 @@
"fideloper/proxy": "^4.0",
"laravel/framework": "^6.2",
"laravel/tinker": "^1.0",
- "laravel/ui": "^1.1"
+ "laravel/ui": "^1.1",
+ "tymon/jwt-auth": "dev-develop"
},
"require-dev": {
"facade/ignition": "^1.4",
diff --git a/motorradig/composer.lock b/motorradig/composer.lock
index fd5cf04..49f1c91 100644
--- a/motorradig/composer.lock
+++ b/motorradig/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "1b9e73ad57a9bbfb35d3c7cc0d815d97",
+ "content-hash": "982e21cc64e27987a84fe2d0caa51fa9",
"packages": [
{
"name": "dnoegel/php-xdg-base-dir",
@@ -734,6 +734,61 @@
],
"time": "2019-10-11T12:16:52+00:00"
},
+ {
+ "name": "lcobucci/jwt",
+ "version": "3.3.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/lcobucci/jwt.git",
+ "reference": "a11ec5f4b4d75d1fcd04e133dede4c317aac9e18"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/lcobucci/jwt/zipball/a11ec5f4b4d75d1fcd04e133dede4c317aac9e18",
+ "reference": "a11ec5f4b4d75d1fcd04e133dede4c317aac9e18",
+ "shasum": ""
+ },
+ "require": {
+ "ext-mbstring": "*",
+ "ext-openssl": "*",
+ "php": "^5.6 || ^7.0"
+ },
+ "require-dev": {
+ "mikey179/vfsstream": "~1.5",
+ "phpmd/phpmd": "~2.2",
+ "phpunit/php-invoker": "~1.1",
+ "phpunit/phpunit": "^5.7 || ^7.3",
+ "squizlabs/php_codesniffer": "~2.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.1-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Lcobucci\\JWT\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Luís Otávio Cobucci Oblonczyk",
+ "email": "lcobucci@gmail.com",
+ "role": "Developer"
+ }
+ ],
+ "description": "A simple library to work with JSON Web Token and JSON Web Signature",
+ "keywords": [
+ "JWS",
+ "jwt"
+ ],
+ "time": "2019-05-24T18:30:49+00:00"
+ },
{
"name": "league/flysystem",
"version": "1.0.57",
@@ -899,6 +954,69 @@
],
"time": "2019-08-30T09:56:44+00:00"
},
+ {
+ "name": "namshi/jose",
+ "version": "7.2.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/namshi/jose.git",
+ "reference": "89a24d7eb3040e285dd5925fcad992378b82bcff"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/namshi/jose/zipball/89a24d7eb3040e285dd5925fcad992378b82bcff",
+ "reference": "89a24d7eb3040e285dd5925fcad992378b82bcff",
+ "shasum": ""
+ },
+ "require": {
+ "ext-date": "*",
+ "ext-hash": "*",
+ "ext-json": "*",
+ "ext-pcre": "*",
+ "ext-spl": "*",
+ "php": ">=5.5",
+ "symfony/polyfill-php56": "^1.0"
+ },
+ "require-dev": {
+ "phpseclib/phpseclib": "^2.0",
+ "phpunit/phpunit": "^4.5|^5.0",
+ "satooshi/php-coveralls": "^1.0"
+ },
+ "suggest": {
+ "ext-openssl": "Allows to use OpenSSL as crypto engine.",
+ "phpseclib/phpseclib": "Allows to use Phpseclib as crypto engine, use version ^2.0."
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Namshi\\JOSE\\": "src/Namshi/JOSE/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Alessandro Nadalin",
+ "email": "alessandro.nadalin@gmail.com"
+ },
+ {
+ "name": "Alessandro Cinelli (cirpo)",
+ "email": "alessandro.cinelli@gmail.com"
+ }
+ ],
+ "description": "JSON Object Signing and Encryption library for PHP.",
+ "keywords": [
+ "JSON Web Signature",
+ "JSON Web Token",
+ "JWS",
+ "json",
+ "jwt",
+ "token"
+ ],
+ "time": "2016-12-05T07:27:31+00:00"
+ },
{
"name": "nesbot/carbon",
"version": "2.25.3",
@@ -2341,6 +2459,62 @@
],
"time": "2019-08-06T08:03:45+00:00"
},
+ {
+ "name": "symfony/polyfill-php56",
+ "version": "v1.13.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-php56.git",
+ "reference": "53dd1cdf3cb986893ccf2b96665b25b3abb384f4"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/53dd1cdf3cb986893ccf2b96665b25b3abb384f4",
+ "reference": "53dd1cdf3cb986893ccf2b96665b25b3abb384f4",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3",
+ "symfony/polyfill-util": "~1.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.13-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Polyfill\\Php56\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "time": "2019-11-27T13:56:44+00:00"
+ },
{
"name": "symfony/polyfill-php72",
"version": "v1.12.0",
@@ -2454,6 +2628,58 @@
],
"time": "2019-08-06T08:03:45+00:00"
},
+ {
+ "name": "symfony/polyfill-util",
+ "version": "v1.13.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-util.git",
+ "reference": "964a67f293b66b95883a5ed918a65354fcd2258f"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/964a67f293b66b95883a5ed918a65354fcd2258f",
+ "reference": "964a67f293b66b95883a5ed918a65354fcd2258f",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.13-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Polyfill\\Util\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony utilities for portability of PHP codes",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compat",
+ "compatibility",
+ "polyfill",
+ "shim"
+ ],
+ "time": "2019-11-27T13:56:44+00:00"
+ },
{
"name": "symfony/process",
"version": "v4.3.5",
@@ -2895,6 +3121,81 @@
"homepage": "https://github.com/tijsverkoyen/CssToInlineStyles",
"time": "2019-10-24T08:53:34+00:00"
},
+ {
+ "name": "tymon/jwt-auth",
+ "version": "dev-develop",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/tymondesigns/jwt-auth.git",
+ "reference": "f57a0ff33f20d2a0c3ebc9e13ce8382a83f921a8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/tymondesigns/jwt-auth/zipball/f57a0ff33f20d2a0c3ebc9e13ce8382a83f921a8",
+ "reference": "f57a0ff33f20d2a0c3ebc9e13ce8382a83f921a8",
+ "shasum": ""
+ },
+ "require": {
+ "illuminate/auth": "^5.1|^6",
+ "illuminate/contracts": "^5.1|^6",
+ "illuminate/http": "^5.1|^6",
+ "illuminate/support": "^5.1|^6",
+ "lcobucci/jwt": "^3.2",
+ "namshi/jose": "^7.0",
+ "nesbot/carbon": "^1.0|^2.0",
+ "php": "^5.5.9|^7.0"
+ },
+ "require-dev": {
+ "cartalyst/sentinel": "^2|^3",
+ "illuminate/console": "^5.1|^6",
+ "illuminate/database": "^5.1|^6",
+ "illuminate/routing": "^5.1|^6",
+ "mockery/mockery": ">=0.9.9",
+ "phpunit/phpunit": "~4.8|~6.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-develop": "1.0-dev"
+ },
+ "laravel": {
+ "aliases": {
+ "JWTAuth": "Tymon\\JWTAuth\\Facades\\JWTAuth",
+ "JWTFactory": "Tymon\\JWTAuth\\Facades\\JWTFactory"
+ },
+ "providers": [
+ "Tymon\\JWTAuth\\Providers\\LaravelServiceProvider"
+ ]
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Tymon\\JWTAuth\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Sean Tymon",
+ "email": "tymon148@gmail.com",
+ "homepage": "https://tymon.xyz",
+ "role": "Developer"
+ }
+ ],
+ "description": "JSON Web Token Authentication for Laravel and Lumen",
+ "homepage": "https://github.com/tymondesigns/jwt-auth",
+ "keywords": [
+ "Authentication",
+ "JSON Web Token",
+ "auth",
+ "jwt",
+ "laravel"
+ ],
+ "time": "2020-01-21T13:04:35+00:00"
+ },
{
"name": "vlucas/phpdotenv",
"version": "v3.6.0",
@@ -4940,7 +5241,9 @@
],
"aliases": [],
"minimum-stability": "dev",
- "stability-flags": [],
+ "stability-flags": {
+ "tymon/jwt-auth": 20
+ },
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
diff --git a/motorradig/config/auth.php b/motorradig/config/auth.php
index aaf982b..38a70e6 100644
--- a/motorradig/config/auth.php
+++ b/motorradig/config/auth.php
@@ -14,7 +14,7 @@ return [
*/
'defaults' => [
- 'guard' => 'web',
+ 'guard' => 'api',
'passwords' => 'users',
],
@@ -42,9 +42,8 @@ return [
],
'api' => [
- 'driver' => 'token',
+ 'driver' => 'jwt',
'provider' => 'users',
- 'hash' => false,
],
],
diff --git a/motorradig/config/jwt.php b/motorradig/config/jwt.php
new file mode 100644
index 0000000..8b7843b
--- /dev/null
+++ b/motorradig/config/jwt.php
@@ -0,0 +1,304 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+return [
+
+ /*
+ |--------------------------------------------------------------------------
+ | JWT Authentication Secret
+ |--------------------------------------------------------------------------
+ |
+ | Don't forget to set this in your .env file, as it will be used to sign
+ | your tokens. A helper command is provided for this:
+ | `php artisan jwt:secret`
+ |
+ | Note: This will be used for Symmetric algorithms only (HMAC),
+ | since RSA and ECDSA use a private/public key combo (See below).
+ |
+ */
+
+ 'secret' => env('JWT_SECRET'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | JWT Authentication Keys
+ |--------------------------------------------------------------------------
+ |
+ | The algorithm you are using, will determine whether your tokens are
+ | signed with a random string (defined in `JWT_SECRET`) or using the
+ | following public & private keys.
+ |
+ | Symmetric Algorithms:
+ | HS256, HS384 & HS512 will use `JWT_SECRET`.
+ |
+ | Asymmetric Algorithms:
+ | RS256, RS384 & RS512 / ES256, ES384 & ES512 will use the keys below.
+ |
+ */
+
+ 'keys' => [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Public Key
+ |--------------------------------------------------------------------------
+ |
+ | A path or resource to your public key.
+ |
+ | E.g. 'file://path/to/public/key'
+ |
+ */
+
+ 'public' => env('JWT_PUBLIC_KEY'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Private Key
+ |--------------------------------------------------------------------------
+ |
+ | A path or resource to your private key.
+ |
+ | E.g. 'file://path/to/private/key'
+ |
+ */
+
+ 'private' => env('JWT_PRIVATE_KEY'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Passphrase
+ |--------------------------------------------------------------------------
+ |
+ | The passphrase for your private key. Can be null if none set.
+ |
+ */
+
+ 'passphrase' => env('JWT_PASSPHRASE'),
+
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | JWT time to live
+ |--------------------------------------------------------------------------
+ |
+ | Specify the length of time (in minutes) that the token will be valid for.
+ | Defaults to 1 hour.
+ |
+ | You can also set this to null, to yield a never expiring token.
+ | Some people may want this behaviour for e.g. a mobile app.
+ | This is not particularly recommended, so make sure you have appropriate
+ | systems in place to revoke the token if necessary.
+ | Notice: If you set this to null you should remove 'exp' element from 'required_claims' list.
+ |
+ */
+
+ 'ttl' => env('JWT_TTL', 60),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Refresh time to live
+ |--------------------------------------------------------------------------
+ |
+ | Specify the length of time (in minutes) that the token can be refreshed
+ | within. I.E. The user can refresh their token within a 2 week window of
+ | the original token being created until they must re-authenticate.
+ | Defaults to 2 weeks.
+ |
+ | You can also set this to null, to yield an infinite refresh time.
+ | Some may want this instead of never expiring tokens for e.g. a mobile app.
+ | This is not particularly recommended, so make sure you have appropriate
+ | systems in place to revoke the token if necessary.
+ |
+ */
+
+ 'refresh_ttl' => env('JWT_REFRESH_TTL', 20160),
+
+ /*
+ |--------------------------------------------------------------------------
+ | JWT hashing algorithm
+ |--------------------------------------------------------------------------
+ |
+ | Specify the hashing algorithm that will be used to sign the token.
+ |
+ | See here: https://github.com/namshi/jose/tree/master/src/Namshi/JOSE/Signer/OpenSSL
+ | for possible values.
+ |
+ */
+
+ 'algo' => env('JWT_ALGO', 'HS256'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Required Claims
+ |--------------------------------------------------------------------------
+ |
+ | Specify the required claims that must exist in any token.
+ | A TokenInvalidException will be thrown if any of these claims are not
+ | present in the payload.
+ |
+ */
+
+ 'required_claims' => [
+ 'iss',
+ 'iat',
+ 'exp',
+ 'nbf',
+ 'sub',
+ 'jti',
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Persistent Claims
+ |--------------------------------------------------------------------------
+ |
+ | Specify the claim keys to be persisted when refreshing a token.
+ | `sub` and `iat` will automatically be persisted, in
+ | addition to the these claims.
+ |
+ | Note: If a claim does not exist then it will be ignored.
+ |
+ */
+
+ 'persistent_claims' => [
+ // 'foo',
+ // 'bar',
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Lock Subject
+ |--------------------------------------------------------------------------
+ |
+ | This will determine whether a `prv` claim is automatically added to
+ | the token. The purpose of this is to ensure that if you have multiple
+ | authentication models e.g. `App\User` & `App\OtherPerson`, then we
+ | should prevent one authentication request from impersonating another,
+ | if 2 tokens happen to have the same id across the 2 different models.
+ |
+ | Under specific circumstances, you may want to disable this behaviour
+ | e.g. if you only have one authentication model, then you would save
+ | a little on token size.
+ |
+ */
+
+ 'lock_subject' => true,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Leeway
+ |--------------------------------------------------------------------------
+ |
+ | This property gives the jwt timestamp claims some "leeway".
+ | Meaning that if you have any unavoidable slight clock skew on
+ | any of your servers then this will afford you some level of cushioning.
+ |
+ | This applies to the claims `iat`, `nbf` and `exp`.
+ |
+ | Specify in seconds - only if you know you need it.
+ |
+ */
+
+ 'leeway' => env('JWT_LEEWAY', 0),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Blacklist Enabled
+ |--------------------------------------------------------------------------
+ |
+ | In order to invalidate tokens, you must have the blacklist enabled.
+ | If you do not want or need this functionality, then set this to false.
+ |
+ */
+
+ 'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),
+
+ /*
+ | -------------------------------------------------------------------------
+ | Blacklist Grace Period
+ | -------------------------------------------------------------------------
+ |
+ | When multiple concurrent requests are made with the same JWT,
+ | it is possible that some of them fail, due to token regeneration
+ | on every request.
+ |
+ | Set grace period in seconds to prevent parallel request failure.
+ |
+ */
+
+ 'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Cookies encryption
+ |--------------------------------------------------------------------------
+ |
+ | By default Laravel encrypt cookies for security reason.
+ | If you decide to not decrypt cookies, you will have to configure Laravel
+ | to not encrypt your cookie token by adding its name into the $except
+ | array available in the middleware "EncryptCookies" provided by Laravel.
+ | see https://laravel.com/docs/master/responses#cookies-and-encryption
+ | for details.
+ |
+ | Set it to true if you want to decrypt cookies.
+ |
+ */
+
+ 'decrypt_cookies' => false,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Providers
+ |--------------------------------------------------------------------------
+ |
+ | Specify the various providers used throughout the package.
+ |
+ */
+
+ 'providers' => [
+
+ /*
+ |--------------------------------------------------------------------------
+ | JWT Provider
+ |--------------------------------------------------------------------------
+ |
+ | Specify the provider that is used to create and decode the tokens.
+ |
+ */
+
+ 'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Authentication Provider
+ |--------------------------------------------------------------------------
+ |
+ | Specify the provider that is used to authenticate users.
+ |
+ */
+
+ 'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Storage Provider
+ |--------------------------------------------------------------------------
+ |
+ | Specify the provider that is used to store tokens in the blacklist.
+ |
+ */
+
+ 'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class,
+
+ ],
+
+];
diff --git a/motorradig/database/migrations/2020_01_28_072844_create_pagecontents_table.php b/motorradig/database/migrations/2020_01_28_072844_create_pagecontents_table.php
new file mode 100644
index 0000000..971f988
--- /dev/null
+++ b/motorradig/database/migrations/2020_01_28_072844_create_pagecontents_table.php
@@ -0,0 +1,33 @@
+bigIncrements('id');
+ $table->string('page')->default('');
+ $table->string('body')->default('');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('pagecontents');
+ }
+}
diff --git a/motorradig/public/js/app.js b/motorradig/public/js/app.js
index 5d1f655..aefdeb9 100644
--- a/motorradig/public/js/app.js
+++ b/motorradig/public/js/app.js
@@ -1990,6 +1990,11 @@ __webpack_require__.r(__webpack_exports__);
//
//
//
+//
+//
+//
+//
+//
/* harmony default export */ __webpack_exports__["default"] = ({
data: function data() {
return {
@@ -2001,17 +2006,18 @@ __webpack_require__.r(__webpack_exports__);
logout: function logout() {
var _this = this;
- console.log("logging out with token " + this.$store.state.user.token); // Empty brackets are an empty object usually containing form data
+ console.log("logging out with token " + this.$store.state.user_token); // Empty brackets are an empty object usually containing form data
axios.post('http://localhost:8000/api/v1/auth/logout', {}, {
headers: {
- 'Authorization': 'Bearer ' + this.$store.state.user.token
+ 'Authorization': 'Bearer ' + this.$store.state.user_token
}
}).then(function (res) {
console.log("Logout successful");
- _this.$store.state.user.token = null;
+ _this.$store.state.user_token = null;
+
+ _this.$router.go(); //Reload page with updated access-based display
- _this.$router.push('/');
})["catch"](function (error) {
console.log("Logout unsuccessful.");
console.log(error);
@@ -2019,6 +2025,31 @@ __webpack_require__.r(__webpack_exports__);
},
editPage: function editPage() {
this.$router.push('/edit_page');
+ },
+ loadPage: function loadPage() {
+ axios.post('http://localhost:8000/api/v1/auth/load_page', {
+ page: 'testpage'
+ }, {
+ headers: {
+ 'Authorization': 'Bearer ' + this.$store.state.user_token
+ }
+ }).then(function (res) {
+ console.log("savePage: Loading Testpage");
+ console.log("Body:");
+ console.log(res.data.body);
+ });
+ },
+ savePage: function savePage() {
+ axios.post('http://localhost:8000/api/v1/auth/save_page', {
+ page: 'testpage',
+ body: 'testbody'
+ }, {
+ headers: {
+ 'Authorization': 'Bearer ' + this.$store.state.user_token
+ }
+ }).then(function (res) {
+ console.log("savePage: Wrote Testpage");
+ });
}
},
created: function created() {
@@ -2117,10 +2148,13 @@ __webpack_require__.r(__webpack_exports__);
}).then(function (res) {
console.log("Login successful. Token=" + res.headers.authorization);
_this.$store.state.user_token = res.headers.authorization;
- _this.$store.state.user = res.data.user; //console.log("Storing user data:");
- //console.log(res.data.user);
- //console.log("Test extraction:");
- //console.log(this.$store.state.user.role);
+ _this.$store.state.user = res.data.user;
+ console.log("Storing user data:");
+ console.log(res.data.user);
+ console.log("Test extraction:");
+ console.log(_this.$store.state.user.role);
+ console.log(_this.$store.state.user.token);
+ console.log(_this.$store.state.user_token);
_this.$router.push('/');
})["catch"](function (error) {
@@ -31196,6 +31230,45 @@ var render = function() {
[_vm._v("Impressum")]
),
_vm._v(" "),
+ _c(
+ "button",
+ {
+ staticClass: "button",
+ on: {
+ click: function($event) {
+ return _vm.savePage()
+ }
+ }
+ },
+ [_vm._v("Save Page")]
+ ),
+ _vm._v(" "),
+ _c(
+ "button",
+ {
+ staticClass: "button",
+ on: {
+ click: function($event) {
+ return _vm.loadPage()
+ }
+ }
+ },
+ [_vm._v("Load Page")]
+ ),
+ _vm._v(" "),
+ _c(
+ "button",
+ {
+ staticClass: "button",
+ on: {
+ click: function($event) {
+ return _vm.logout()
+ }
+ }
+ },
+ [_vm._v("Logout")]
+ ),
+ _vm._v(" "),
_c(
"router-link",
{ staticClass: "button", attrs: { to: { name: "Login" } } },
diff --git a/motorradig/resources/js/views/Main.vue b/motorradig/resources/js/views/Main.vue
index 4a60699..55c0de6 100644
--- a/motorradig/resources/js/views/Main.vue
+++ b/motorradig/resources/js/views/Main.vue
@@ -19,10 +19,15 @@
+
+
+
+
Log-In
+
@@ -75,18 +80,18 @@
methods: {
logout() {
- console.log("logging out with token "+this.$store.state.user.token);
+ console.log("logging out with token "+this.$store.state.user_token);
// Empty brackets are an empty object usually containing form data
axios.post('http://localhost:8000/api/v1/auth/logout',{}, {
headers: {
- 'Authorization': 'Bearer ' + this.$store.state.user.token
+ 'Authorization': 'Bearer ' + this.$store.state.user_token
}
})
.then(res => {
console.log("Logout successful");
- this.$store.state.user.token=null;
- this.$router.push('/');
+ this.$store.state.user_token=null;
+ this.$router.go();//Reload page with updated access-based display
}
)
.catch(error => {
@@ -96,6 +101,38 @@
},
editPage() {
this.$router.push('/edit_page');
+ },
+ loadPage() {
+ axios.post('http://localhost:8000/api/v1/auth/load_page',{
+ page: 'testpage'
+
+ }, {
+ headers: {
+ 'Authorization': 'Bearer ' + this.$store.state.user_token
+ }
+ })
+ .then(res => {
+ console.log("savePage: Loading Testpage");
+ console.log("Body:");
+ console.log(res.data.body);
+ }
+ )
+ }
+ ,
+ savePage() {
+ axios.post('http://localhost:8000/api/v1/auth/save_page',{
+ page: 'testpage',
+ body: 'testbody'
+
+ }, {
+ headers: {
+ 'Authorization': 'Bearer ' + this.$store.state.user_token
+ }
+ })
+ .then(res => {
+ console.log("savePage: Wrote Testpage");
+ }
+ )
}
}
,
diff --git a/motorradig/resources/js/views/auth/Login.vue b/motorradig/resources/js/views/auth/Login.vue
index d591f3c..785f641 100644
--- a/motorradig/resources/js/views/auth/Login.vue
+++ b/motorradig/resources/js/views/auth/Login.vue
@@ -71,10 +71,13 @@
console.log("Login successful. Token="+res.headers.authorization);
this.$store.state.user_token=res.headers.authorization;
this.$store.state.user=res.data.user;
- //console.log("Storing user data:");
- //console.log(res.data.user);
- //console.log("Test extraction:");
- //console.log(this.$store.state.user.role);
+
+ console.log("Storing user data:");
+ console.log(res.data.user);
+ console.log("Test extraction:");
+ console.log(this.$store.state.user.role);
+ console.log(this.$store.state.user.token);
+ console.log(this.$store.state.user_token);
this.$router.push('/');
}
)
diff --git a/motorradig/routes/api.php b/motorradig/routes/api.php
index 1677912..fe50f69 100644
--- a/motorradig/routes/api.php
+++ b/motorradig/routes/api.php
@@ -36,8 +36,11 @@ Route::prefix('v1')->group(function () {
// Logout user from application
Route::post('logout', 'AuthController@logout');
- //TEST
- Route::post('showme', 'UserController@showme');
+ //Save Page Content
+ Route::post('save_page', 'PageController@save_page');
+
+ //Load Page Content
+ Route::post('load_page', 'PageController@load_page');
});
});