From 0d929748b76651016bbcfcf02e4b210b60c32290 Mon Sep 17 00:00:00 2001 From: Kekskurse Date: Thu, 25 Apr 2019 17:33:15 +0200 Subject: [PATCH] Test API --- app/Exceptions/NoPermissionException.php | 9 + app/Exceptions/NotLoggedInException.php | 9 + app/Exceptions/ResourceNotFound.php | 9 + .../Controllers/API/AccountController.php | 50 ++++ app/Http/Controllers/GUI/AccessController.php | 61 ++++ .../Controllers/GUI/AccountController.php | 109 +++++++- app/Http/Resources/API/User.php | 29 ++ app/Providers/AuthServiceProvider.php | 3 + bootstrap/app.php | 5 + composer.json | 9 +- composer.lock | 263 ++++++++++-------- .../2019_04_25_125710_fix_mail_bug.php | 40 +++ resources/views/access/list.php | 29 ++ resources/views/account/profile.php | 73 +++++ resources/views/layout/top.php | 5 +- routes/web.php | 35 ++- 16 files changed, 614 insertions(+), 124 deletions(-) create mode 100644 app/Exceptions/NoPermissionException.php create mode 100644 app/Exceptions/NotLoggedInException.php create mode 100644 app/Exceptions/ResourceNotFound.php create mode 100644 app/Http/Controllers/API/AccountController.php create mode 100644 app/Http/Controllers/GUI/AccessController.php create mode 100644 app/Http/Resources/API/User.php create mode 100644 database/migrations/2019_04_25_125710_fix_mail_bug.php create mode 100644 resources/views/access/list.php create mode 100644 resources/views/account/profile.php diff --git a/app/Exceptions/NoPermissionException.php b/app/Exceptions/NoPermissionException.php new file mode 100644 index 0000000..e7ee7c9 --- /dev/null +++ b/app/Exceptions/NoPermissionException.php @@ -0,0 +1,9 @@ +admin) { + throw new NoPermissionException(); + } + + $users = User::query()->paginate(100); + $response->setPagination( + $users->currentPage(), + $users->lastPage(), + $users->perPage() + ); + return $response->withData(\App\Http\Resources\API\User::collection(($users))); + } + + public function getUser(Response $response, $id) { + if(!Auth::check()) { + throw new NotLoggedInException(); + } + + if(!(Auth::user()->admin || Auth::user()->id == $id)) { + throw new NoPermissionException(); + } + + $user = User::query()->where("id", "=", $id)->first(); + + if($user == null) { + throw new ResourceNotFound(); + } + + return $response->withData(new \App\Http\Resources\API\User($user)); + } +} diff --git a/app/Http/Controllers/GUI/AccessController.php b/app/Http/Controllers/GUI/AccessController.php new file mode 100644 index 0000000..ee598c6 --- /dev/null +++ b/app/Http/Controllers/GUI/AccessController.php @@ -0,0 +1,61 @@ +where("user_id", "=", Auth::user()->id)->get(); + + return view("access/list", ["access" => $access]); + } + + public function removeAccess(Request $request) { + if(!Auth::check()) { + abort(401); + } + + $access = AppAccess::query()->where("id", "=", $request->id)->firstOrFail(); + if($access->user_id != Auth::user()->id) { + abort(401); + } + + RefreshToken::query()->where("access_id", "=", $access->id)->delete(); + \App\Models\AccessToken::query()->where("access_id", "=", $access->id)->delete(); + AppCode::query()->where("access_id", "=", $access->id)->delete(); + $access->delete(); + + + return redirect("/gui/access"); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/GUI/AccountController.php b/app/Http/Controllers/GUI/AccountController.php index a09d323..abe1b60 100644 --- a/app/Http/Controllers/GUI/AccountController.php +++ b/app/Http/Controllers/GUI/AccountController.php @@ -13,6 +13,7 @@ use App\Models\Mail; use App\Models\Setting; use App\Models\User; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; class AccountController extends Controller @@ -73,6 +74,10 @@ class AccountController extends Controller $user->username = $request->input("username"); $user->password = password_hash($request->input("password"), PASSWORD_BCRYPT); + if($invite != null) { + $user->inviteCode = $invite->code; + } + //Make first user an admin $count = User::query()->count("*"); if($count == 1) { @@ -142,16 +147,114 @@ class AccountController extends Controller } $mail->status = "valide"; - $mail->primary = true; - $mails = Mail::query()->where("user_id", "=", $mail->user_id)->where("primary", "=", true)->get("*"); + $user = User::query()->where("id", "=", $mail->user_id)->firstOrFail(); + if($user->getMail() == null) { + $mail->primary = true; + } + + //Dont set new Mails as primary + /*$mails = Mail::query()->where("user_id", "=", $mail->user_id)->where("primary", "=", true)->get("*"); + foreach($mails as $m) { + $m->primary = false; + $m->saveOrFail(); + }*/ + + $mail->saveOrFail(); + echo "E-Mail wurde validiert"; + } + + public function profileView() { + if(!Auth::check()) { + abort(401); + } + + $mails = Mail::query()->where("user_id", "=", Auth::user()->id)->get(); + + return view('account/profile', ["mails" => $mails]); + } + + public function addMail(Request $request) { + if(!Auth::check()) { + abort(401); + } + + $this->validate($request, [ + 'mail' => 'required|email|unique:mails' + ]); + + $mail = new Mail(); + $mail->createValidationToken(); + $mail->mail = $request->input("mail"); + $mail->primary = false; + $mail->status = "waiting"; + $mail->user_id = Auth::user()->id; + + $mail->saveOrFail(); + + $this->dispatch(new ValidateMailAddressJob($mail)); + + return redirect("/gui/profile"); + } + + public function changePrimaryMail(Request $request) { + if(!Auth::check()) { + abort(401); + } + + $mail = Mail::query()->where("id", "=", $request->input("mail"))->firstOrFail(); + if($mail->user_id != Auth::user()->id) { + abort(401); + } + + if($mail->status != "valide") { + return "Mail not valide"; + } + + $mails = Mail::query()->where("user_id", "=", Auth::user()->id)->get(); foreach($mails as $m) { $m->primary = false; $m->saveOrFail(); } + $mail->primary = true; $mail->saveOrFail(); - echo "E-Mail wurde validiert"; + + return redirect("/gui/profile"); + } + + public function removeMail(Request $request) { + if(!Auth::check()) { + abort(401); + } + + $mail = Mail::query()->where("id", "=", $request->input("mail"))->firstOrFail(); + if($mail->user_id != Auth::user()->id) { + abort(401); + } + + if($mail->primary) { + return "You cant delete your primary mail"; + } + + $mail->delete(); + return redirect("/gui/profile"); + } + + public function changePassword(Request $request) { + if(!Auth::check()) { + abort(401); + } + + $this->validate($request, [ + 'password' => 'required|min:8' + ]); + + $user = Auth::user(); + $user->password = password_hash($request->input("password"), PASSWORD_BCRYPT); + $user->saveOrFail(); + + return redirect('/gui/logout'); } diff --git a/app/Http/Resources/API/User.php b/app/Http/Resources/API/User.php new file mode 100644 index 0000000..83fecf0 --- /dev/null +++ b/app/Http/Resources/API/User.php @@ -0,0 +1,29 @@ + (int)$this->id, + 'username' => $this->username, + 'created_at' => $this->created_at, + 'updated_at' => $this->created_at, + 'primaryMail' => $this->getMail(), + 'status' => $this->status, + 'inviteCode' => $this->inviteCode, + 'developer' => (bool)$this->developer, + 'admin' => (bool)$this->admin + ]; + } +} \ No newline at end of file diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 70d090d..746d81e 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -62,6 +62,9 @@ class AuthServiceProvider extends ServiceProvider } $accessToken = AccessToken::query()->where("token", "=", $token)->first(); + if($accessToken == null) { + return null; + } if(time() > strtotime($accessToken->expires_at)) { return null; } diff --git a/bootstrap/app.php b/bootstrap/app.php index b1aa91b..7e80da3 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -61,6 +61,11 @@ $app->singleton( // App\Http\Middleware\ExampleMiddleware::class // ]); +$app->middleware(array( + TaGeSo\APIResponse\Middelware::class +)); + + $app->routeMiddleware([ 'auth' => App\Http\Middleware\Authenticate::class, 'gui' => \App\Http\Middleware\View::class diff --git a/composer.json b/composer.json index 8a8299b..9056632 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,8 @@ "php": ">=7.1.3", "laravel/lumen-framework": "5.8.*", "vlucas/phpdotenv": "^3.3", - "phpmailer/phpmailer": "~6.0" + "phpmailer/phpmailer": "~6.0", + "tageso/api-response": "*" }, "require-dev": { "fzaninotto/faker": "^1.4", @@ -39,6 +40,12 @@ "sort-packages": true, "optimize-autoloader": true }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/tageso/apiResponse.git" + } + ], "minimum-stability": "dev", "prefer-stable": true } diff --git a/composer.lock b/composer.lock index 9de8f45..0a2832c 100644 --- a/composer.lock +++ b/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": "74d08bf87436d07aa38f8ee1bcbdfb68", + "content-hash": "265697a07793434d0d8ac306debafc74", "packages": [ { "name": "doctrine/inflector", @@ -240,16 +240,16 @@ }, { "name": "illuminate/auth", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/auth.git", - "reference": "47647ba0b0fbc2dae3fc1f9533ed9acacf320457" + "reference": "a3a396e03eb96b182364b7bdf4cd3d97f64b1dac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/auth/zipball/47647ba0b0fbc2dae3fc1f9533ed9acacf320457", - "reference": "47647ba0b0fbc2dae3fc1f9533ed9acacf320457", + "url": "https://api.github.com/repos/illuminate/auth/zipball/a3a396e03eb96b182364b7bdf4cd3d97f64b1dac", + "reference": "a3a396e03eb96b182364b7bdf4cd3d97f64b1dac", "shasum": "" }, "require": { @@ -287,20 +287,20 @@ ], "description": "The Illuminate Auth package.", "homepage": "https://laravel.com", - "time": "2019-04-16T01:46:33+00:00" + "time": "2019-04-22T18:45:14+00:00" }, { "name": "illuminate/broadcasting", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/broadcasting.git", - "reference": "f6806fbcc33cfa930a4f0b43018b416f72dfc5c1" + "reference": "4e855c50e5fe18272571db6c303f6ca096b8406b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/broadcasting/zipball/f6806fbcc33cfa930a4f0b43018b416f72dfc5c1", - "reference": "f6806fbcc33cfa930a4f0b43018b416f72dfc5c1", + "url": "https://api.github.com/repos/illuminate/broadcasting/zipball/4e855c50e5fe18272571db6c303f6ca096b8406b", + "reference": "4e855c50e5fe18272571db6c303f6ca096b8406b", "shasum": "" }, "require": { @@ -338,11 +338,11 @@ ], "description": "The Illuminate Broadcasting package.", "homepage": "https://laravel.com", - "time": "2019-03-27T10:17:08+00:00" + "time": "2019-04-22T18:38:59+00:00" }, { "name": "illuminate/bus", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/bus.git", @@ -387,16 +387,16 @@ }, { "name": "illuminate/cache", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/cache.git", - "reference": "f5f2c61956970fbfe93259a9e47a6096608377f7" + "reference": "f25be6bcdb77da215f9c7fd16899c213c8a58beb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/cache/zipball/f5f2c61956970fbfe93259a9e47a6096608377f7", - "reference": "f5f2c61956970fbfe93259a9e47a6096608377f7", + "url": "https://api.github.com/repos/illuminate/cache/zipball/f25be6bcdb77da215f9c7fd16899c213c8a58beb", + "reference": "f25be6bcdb77da215f9c7fd16899c213c8a58beb", "shasum": "" }, "require": { @@ -432,11 +432,11 @@ ], "description": "The Illuminate Cache package.", "homepage": "https://laravel.com", - "time": "2019-04-12T12:37:19+00:00" + "time": "2019-04-22T18:38:59+00:00" }, { "name": "illuminate/config", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/config.git", @@ -480,7 +480,7 @@ }, { "name": "illuminate/console", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/console.git", @@ -531,16 +531,16 @@ }, { "name": "illuminate/container", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/container.git", - "reference": "b984960d2634c6be97b0dd368a8953e8c4e06ec7" + "reference": "9405989993a48c2cd50ad1e5b2b08a33383c3807" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/container/zipball/b984960d2634c6be97b0dd368a8953e8c4e06ec7", - "reference": "b984960d2634c6be97b0dd368a8953e8c4e06ec7", + "url": "https://api.github.com/repos/illuminate/container/zipball/9405989993a48c2cd50ad1e5b2b08a33383c3807", + "reference": "9405989993a48c2cd50ad1e5b2b08a33383c3807", "shasum": "" }, "require": { @@ -572,20 +572,20 @@ ], "description": "The Illuminate Container package.", "homepage": "https://laravel.com", - "time": "2019-03-03T15:13:35+00:00" + "time": "2019-04-22T13:12:35+00:00" }, { "name": "illuminate/contracts", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", - "reference": "053c578b5a95fc50fa62266ff720ef74790e938e" + "reference": "0b3cbe19051c9a8c247091cc0867d3b65250d093" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/contracts/zipball/053c578b5a95fc50fa62266ff720ef74790e938e", - "reference": "053c578b5a95fc50fa62266ff720ef74790e938e", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/0b3cbe19051c9a8c247091cc0867d3b65250d093", + "reference": "0b3cbe19051c9a8c247091cc0867d3b65250d093", "shasum": "" }, "require": { @@ -616,20 +616,20 @@ ], "description": "The Illuminate Contracts package.", "homepage": "https://laravel.com", - "time": "2019-04-16T12:47:20+00:00" + "time": "2019-04-21T18:51:09+00:00" }, { "name": "illuminate/database", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/database.git", - "reference": "41f6e70fc500f8b6584e4899a176f8010e0fc077" + "reference": "a68f2ea08627af047b9d58feb2b1e3697a8bf298" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/database/zipball/41f6e70fc500f8b6584e4899a176f8010e0fc077", - "reference": "41f6e70fc500f8b6584e4899a176f8010e0fc077", + "url": "https://api.github.com/repos/illuminate/database/zipball/a68f2ea08627af047b9d58feb2b1e3697a8bf298", + "reference": "a68f2ea08627af047b9d58feb2b1e3697a8bf298", "shasum": "" }, "require": { @@ -676,11 +676,11 @@ "orm", "sql" ], - "time": "2019-04-15T13:11:55+00:00" + "time": "2019-04-22T19:09:23+00:00" }, { "name": "illuminate/encryption", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/encryption.git", @@ -727,7 +727,7 @@ }, { "name": "illuminate/events", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/events.git", @@ -772,7 +772,7 @@ }, { "name": "illuminate/filesystem", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/filesystem.git", @@ -824,7 +824,7 @@ }, { "name": "illuminate/hashing", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/hashing.git", @@ -868,16 +868,16 @@ }, { "name": "illuminate/http", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/http.git", - "reference": "5a3f9268561a8df637904dead361ed4e6b4eaf85" + "reference": "c4a4db1ff72d2344e9fef585128a6792aceb8d2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/http/zipball/5a3f9268561a8df637904dead361ed4e6b4eaf85", - "reference": "5a3f9268561a8df637904dead361ed4e6b4eaf85", + "url": "https://api.github.com/repos/illuminate/http/zipball/c4a4db1ff72d2344e9fef585128a6792aceb8d2d", + "reference": "c4a4db1ff72d2344e9fef585128a6792aceb8d2d", "shasum": "" }, "require": { @@ -911,11 +911,11 @@ ], "description": "The Illuminate Http package.", "homepage": "https://laravel.com", - "time": "2019-03-29T18:03:35+00:00" + "time": "2019-04-22T18:38:59+00:00" }, { "name": "illuminate/log", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/log.git", @@ -960,7 +960,7 @@ }, { "name": "illuminate/pagination", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/pagination.git", @@ -1005,7 +1005,7 @@ }, { "name": "illuminate/pipeline", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/pipeline.git", @@ -1049,16 +1049,16 @@ }, { "name": "illuminate/queue", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/queue.git", - "reference": "ebd11d4c9e6b0c9593f466782f1d53eda4b1830a" + "reference": "307904b5be3ed118009b67b735772e9964e92bad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/queue/zipball/ebd11d4c9e6b0c9593f466782f1d53eda4b1830a", - "reference": "ebd11d4c9e6b0c9593f466782f1d53eda4b1830a", + "url": "https://api.github.com/repos/illuminate/queue/zipball/307904b5be3ed118009b67b735772e9964e92bad", + "reference": "307904b5be3ed118009b67b735772e9964e92bad", "shasum": "" }, "require": { @@ -1104,11 +1104,11 @@ ], "description": "The Illuminate Queue package.", "homepage": "https://laravel.com", - "time": "2019-02-23T14:59:33+00:00" + "time": "2019-04-22T18:45:14+00:00" }, { "name": "illuminate/session", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/session.git", @@ -1159,16 +1159,16 @@ }, { "name": "illuminate/support", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "5541fa4ee4b5ab4635056fae0eecad7d328b86b4" + "reference": "e1b62fbf219dc1fa7154b0abef3975a41038bca7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/5541fa4ee4b5ab4635056fae0eecad7d328b86b4", - "reference": "5541fa4ee4b5ab4635056fae0eecad7d328b86b4", + "url": "https://api.github.com/repos/illuminate/support/zipball/e1b62fbf219dc1fa7154b0abef3975a41038bca7", + "reference": "e1b62fbf219dc1fa7154b0abef3975a41038bca7", "shasum": "" }, "require": { @@ -1216,20 +1216,20 @@ ], "description": "The Illuminate Support package.", "homepage": "https://laravel.com", - "time": "2019-04-14T05:44:06+00:00" + "time": "2019-04-22T13:12:35+00:00" }, { "name": "illuminate/translation", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/translation.git", - "reference": "7d9cc548c9bb99fb344ab7b78f2f067372beedbd" + "reference": "f42b8ab5016acb6f4971bb851cbdee1949a135bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/translation/zipball/7d9cc548c9bb99fb344ab7b78f2f067372beedbd", - "reference": "7d9cc548c9bb99fb344ab7b78f2f067372beedbd", + "url": "https://api.github.com/repos/illuminate/translation/zipball/f42b8ab5016acb6f4971bb851cbdee1949a135bf", + "reference": "f42b8ab5016acb6f4971bb851cbdee1949a135bf", "shasum": "" }, "require": { @@ -1262,11 +1262,11 @@ ], "description": "The Illuminate Translation package.", "homepage": "https://laravel.com", - "time": "2019-02-18T18:37:54+00:00" + "time": "2019-04-22T13:12:35+00:00" }, { "name": "illuminate/validation", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/validation.git", @@ -1318,16 +1318,16 @@ }, { "name": "illuminate/view", - "version": "v5.8.12", + "version": "v5.8.14", "source": { "type": "git", "url": "https://github.com/illuminate/view.git", - "reference": "329b5b1fa3461b8c730d1c909f710e72f5c2fa03" + "reference": "a62ef6b6c4392a8bb5cf3af5f5076459525286c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/view/zipball/329b5b1fa3461b8c730d1c909f710e72f5c2fa03", - "reference": "329b5b1fa3461b8c730d1c909f710e72f5c2fa03", + "url": "https://api.github.com/repos/illuminate/view/zipball/a62ef6b6c4392a8bb5cf3af5f5076459525286c5", + "reference": "a62ef6b6c4392a8bb5cf3af5f5076459525286c5", "shasum": "" }, "require": { @@ -1363,20 +1363,20 @@ ], "description": "The Illuminate View package.", "homepage": "https://laravel.com", - "time": "2019-04-12T13:14:04+00:00" + "time": "2019-04-17T14:14:38+00:00" }, { "name": "laravel/lumen-framework", - "version": "v5.8.4", + "version": "v5.8.5", "source": { "type": "git", "url": "https://github.com/laravel/lumen-framework.git", - "reference": "21cd20da632e67ec5bc53b56a51a717ff7202e97" + "reference": "0d5b7e655450a04dc9fe75dd956057c95bad4811" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/lumen-framework/zipball/21cd20da632e67ec5bc53b56a51a717ff7202e97", - "reference": "21cd20da632e67ec5bc53b56a51a717ff7202e97", + "url": "https://api.github.com/repos/laravel/lumen-framework/zipball/0d5b7e655450a04dc9fe75dd956057c95bad4811", + "reference": "0d5b7e655450a04dc9fe75dd956057c95bad4811", "shasum": "" }, "require": { @@ -1448,7 +1448,7 @@ "laravel", "lumen" ], - "time": "2019-03-21T17:35:25+00:00" + "time": "2019-04-19T14:18:28+00:00" }, { "name": "monolog/monolog", @@ -1530,16 +1530,16 @@ }, { "name": "nesbot/carbon", - "version": "2.16.3", + "version": "2.17.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "373d9f0d58651af366435148c39beb702c2b7ef4" + "reference": "9b49d637ad009e5e211142bc7492adcb19dbd645" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/373d9f0d58651af366435148c39beb702c2b7ef4", - "reference": "373d9f0d58651af366435148c39beb702c2b7ef4", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/9b49d637ad009e5e211142bc7492adcb19dbd645", + "reference": "9b49d637ad009e5e211142bc7492adcb19dbd645", "shasum": "" }, "require": { @@ -1549,9 +1549,9 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.14 || ^3.0", - "kylekatarnls/multi-tester": "^0.1", + "kylekatarnls/multi-tester": "^1.1", "phpmd/phpmd": "^2.6", - "phpstan/phpstan": "^0.10.8", + "phpstan/phpstan": "^0.11", "phpunit/phpunit": "^7.5 || ^8.0", "squizlabs/php_codesniffer": "^3.4" }, @@ -1586,7 +1586,7 @@ "datetime", "time" ], - "time": "2019-04-06T17:09:23+00:00" + "time": "2019-04-17T08:51:36+00:00" }, { "name": "nikic/fast-route", @@ -1957,7 +1957,7 @@ }, { "name": "symfony/console", - "version": "v4.2.6", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", @@ -2097,7 +2097,7 @@ }, { "name": "symfony/debug", - "version": "v4.2.6", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", @@ -2153,7 +2153,7 @@ }, { "name": "symfony/event-dispatcher", - "version": "v4.2.6", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -2217,7 +2217,7 @@ }, { "name": "symfony/finder", - "version": "v4.2.6", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", @@ -2266,16 +2266,16 @@ }, { "name": "symfony/http-foundation", - "version": "v4.2.6", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "5b7ab6beaa5b053b8d3c9b13367ada9b292e12e1" + "reference": "6ebbe61f48069033225c9d3fa7eb5ed116d766d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/5b7ab6beaa5b053b8d3c9b13367ada9b292e12e1", - "reference": "5b7ab6beaa5b053b8d3c9b13367ada9b292e12e1", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/6ebbe61f48069033225c9d3fa7eb5ed116d766d6", + "reference": "6ebbe61f48069033225c9d3fa7eb5ed116d766d6", "shasum": "" }, "require": { @@ -2316,20 +2316,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2019-03-30T15:58:42+00:00" + "time": "2019-04-17T14:56:00+00:00" }, { "name": "symfony/http-kernel", - "version": "v4.2.6", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "72f5f8f9dd6e6fbda0220ded537610ad20fa2ce8" + "reference": "3db83303dbc1da9777e5ff63423b8b7fde423a1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/72f5f8f9dd6e6fbda0220ded537610ad20fa2ce8", - "reference": "72f5f8f9dd6e6fbda0220ded537610ad20fa2ce8", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/3db83303dbc1da9777e5ff63423b8b7fde423a1b", + "reference": "3db83303dbc1da9777e5ff63423b8b7fde423a1b", "shasum": "" }, "require": { @@ -2405,7 +2405,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2019-04-16T07:20:25+00:00" + "time": "2019-04-17T16:17:13+00:00" }, { "name": "symfony/polyfill-ctype", @@ -2581,7 +2581,7 @@ }, { "name": "symfony/process", - "version": "v4.2.6", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/process.git", @@ -2630,7 +2630,7 @@ }, { "name": "symfony/translation", - "version": "v4.2.6", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", @@ -2705,16 +2705,16 @@ }, { "name": "symfony/var-dumper", - "version": "v4.2.6", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "f42850fa32b8d7a35a75510810f6ef597674be74" + "reference": "e760a38e12b15032325e64be63f7ffc1817af617" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/f42850fa32b8d7a35a75510810f6ef597674be74", - "reference": "f42850fa32b8d7a35a75510810f6ef597674be74", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/e760a38e12b15032325e64be63f7ffc1817af617", + "reference": "e760a38e12b15032325e64be63f7ffc1817af617", "shasum": "" }, "require": { @@ -2777,7 +2777,46 @@ "debug", "dump" ], - "time": "2019-04-11T11:27:41+00:00" + "time": "2019-04-17T14:57:01+00:00" + }, + { + "name": "tageso/api-response", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/tageso/apiResponse.git", + "reference": "510e4233d31506f5bd4e6d3456d55297d8c0376d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tageso/apiResponse/zipball/510e4233d31506f5bd4e6d3456d55297d8c0376d", + "reference": "510e4233d31506f5bd4e6d3456d55297d8c0376d", + "shasum": "" + }, + "require": { + "laravel/lumen-framework": "5.*" + }, + "type": "library", + "autoload": { + "psr-0": { + "TaGeSo\\APIResponse\\": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "soeren", + "email": "hello@kekskurse.de" + } + ], + "description": "Lumen API Response Class and Middelware", + "support": { + "source": "https://github.com/tageso/apiResponse/tree/master", + "issues": "https://github.com/tageso/apiResponse/issues" + }, + "time": "2019-04-25T15:20:37+00:00" }, { "name": "vlucas/phpdotenv", @@ -3671,16 +3710,16 @@ }, { "name": "phpunit/phpunit", - "version": "7.5.8", + "version": "7.5.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c29c0525cf4572c11efe1db49a8b8aee9dfac58a" + "reference": "134669cf0eeac3f79bc7f0c793efbc158bffc160" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c29c0525cf4572c11efe1db49a8b8aee9dfac58a", - "reference": "c29c0525cf4572c11efe1db49a8b8aee9dfac58a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/134669cf0eeac3f79bc7f0c793efbc158bffc160", + "reference": "134669cf0eeac3f79bc7f0c793efbc158bffc160", "shasum": "" }, "require": { @@ -3751,7 +3790,7 @@ "testing", "xunit" ], - "time": "2019-03-26T13:23:54+00:00" + "time": "2019-04-19T15:50:46+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -3920,16 +3959,16 @@ }, { "name": "sebastian/environment", - "version": "4.1.0", + "version": "4.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "6fda8ce1974b62b14935adc02a9ed38252eca656" + "reference": "3095910f0f0fb155ac4021fc51a4a7a39ac04e8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6fda8ce1974b62b14935adc02a9ed38252eca656", - "reference": "6fda8ce1974b62b14935adc02a9ed38252eca656", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/3095910f0f0fb155ac4021fc51a4a7a39ac04e8a", + "reference": "3095910f0f0fb155ac4021fc51a4a7a39ac04e8a", "shasum": "" }, "require": { @@ -3944,7 +3983,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -3969,7 +4008,7 @@ "environment", "hhvm" ], - "time": "2019-02-01T05:27:49+00:00" + "time": "2019-04-25T07:55:20+00:00" }, { "name": "sebastian/exporter", diff --git a/database/migrations/2019_04_25_125710_fix_mail_bug.php b/database/migrations/2019_04_25_125710_fix_mail_bug.php new file mode 100644 index 0000000..1b304da --- /dev/null +++ b/database/migrations/2019_04_25_125710_fix_mail_bug.php @@ -0,0 +1,40 @@ +dropUnique('email'); + $table->dropForeign('mails_user_id_foreign'); + $table->dropUnique('unique_primary_email'); + $table->foreign('user_id')->references('id')->on('users'); + }); + + Schema::table("users", function(Blueprint $table) { + // e.g. $table->dropUnique('email'); + $table->string('inviteCode')->nullable()->default(null)->comment("Invite code user used to register"); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + return false; + // Vorwärts immer, rückwerts nimmer + } +} diff --git a/resources/views/access/list.php b/resources/views/access/list.php new file mode 100644 index 0000000..172125c --- /dev/null +++ b/resources/views/access/list.php @@ -0,0 +1,29 @@ + +
+
+

App Access

+

Here is a list of all Apps who have access to your Account. You can remove the Access if you want to.

+ + + + + + + + + + + + + + + +
App NameApp BeschreibungZugriff seitAktionen
getApp()->name; ?>getApp()->description; ?>created_at->format("d.m.Y H:i"); ?>Remove Access
+
+
+ + \ No newline at end of file diff --git a/resources/views/account/profile.php b/resources/views/account/profile.php new file mode 100644 index 0000000..8027b07 --- /dev/null +++ b/resources/views/account/profile.php @@ -0,0 +1,73 @@ + +
+
+ +
+
+

Profile

+ Here you can change your Profile Settings. +
+
+

E-Mail adresses

+ + + + + + + + + + + + + + + +
E-MailStatusPrimary E-MailAction
mail; ?>status); ?>primary) { echo ''; } ?> + + + primary) { + echo 'Remove '; + } + if($mail->status == "valide" && !$mail->primary) { + echo 'Use as Primary Mail Adress '; + } + ?> + + +
+
+ Add a new E-Mail adresse +

You can add multible Mail Addresses to your Account, to add another one enter the address in the form below. After that we send you a E-Mail to validate the Address.

+
+
+ +
+
+
+

Change your Account Password.

+
+
+ +
+
+
+
+
+ \ No newline at end of file diff --git a/resources/views/layout/top.php b/resources/views/layout/top.php index fb05807..e6da2a8 100644 --- a/resources/views/layout/top.php +++ b/resources/views/layout/top.php @@ -68,8 +68,9 @@ username; ?> diff --git a/routes/web.php b/routes/web.php index 1386047..bc6d256 100644 --- a/routes/web.php +++ b/routes/web.php @@ -12,11 +12,19 @@ */ $router->get('/', ['middleware' => 'gui', 'uses' => 'GUI\PublicController@index']); -$router->get('/api/v4/user', ['uses' => 'oAuthController@getUserTMP']); -$router->get('/api/v4/groups', ['uses' => 'oAuthController@getGroupsTMP']); +#$router->get('/api/v4/user', ['uses' => 'oAuthController@getUserTMP']); +#$router->get('/api/v4/groups', ['uses' => 'oAuthController@getGroupsTMP']); //Gitlab like oauth $router->group(['prefix' => 'gitlab', 'middleware' => 'gui'], function () use ($router) { + $router->group(['prefix' => 'oauth'], function () use ($router) { + $router->get("/authorize", ['middleware' => 'gui', 'uses' => 'oAuthController@authorizeView']); + $router->post("/authorize", ['middleware' => 'gui', 'uses' => 'oAuthController@authorizeDo']); + $router->post("/token", ['uses' => 'oAuthController@token']); + }); + + $router->get('/api/v4/user', ['uses' => 'oAuthController@getUserTMP']); + $router->get('/api/v4/groups', ['uses' => 'oAuthController@getGroupsTMP']); }); @@ -29,7 +37,13 @@ $router->group(['prefix' => 'oauth'], function () use ($router) { //Internal API -$router->group(['prefix' => 'api'], function () use ($router) { +$router->group(['prefix' => 'api', 'middleware' => 'auth'], function () use ($router) { + $router->group(['prefix' => 'v1'], function () use ($router) { + $router->group(['prefix' => 'account'], function () use ($router) { + $router->get("/", ['uses' => 'API\AccountController@getUsers']); + $router->get("/{id}", ['uses' => 'API\AccountController@getUser']); + }); + }); }); $router->group(['prefix' => 'gui', 'middleware' => 'gui'], function () use ($router) { @@ -66,9 +80,18 @@ $router->group(['prefix' => 'gui', 'middleware' => 'gui'], function () use ($rou - $router->get('user/profile', function () { - // Uses Auth Middleware - }); + + + $router->get('/profile', ['uses' => 'GUI\AccountController@profileView']); + $router->post('/profile/addMail', ['uses' => 'GUI\AccountController@addMail']); + $router->get('/profile/changePrimaryMail', ['uses' => 'GUI\AccountController@changePrimaryMail']); + $router->get('/profile/removeMail', ['uses' => 'GUI\AccountController@removeMail']); + $router->post('/profile/changePassword', ['uses' => 'GUI\AccountController@changePassword']); + + $router->get('/access', ['uses' => 'GUI\AccessController@listAccess']); + $router->get('/access/rm', ['uses' => 'GUI\AccessController@removeAccess']); + + }); /*$router->group(['prefix' => 'api'], function () use ($router) {