diff --git a/Dockerfile-app b/Dockerfile-app new file mode 100644 index 0000000..a0a2c30 --- /dev/null +++ b/Dockerfile-app @@ -0,0 +1,12 @@ +FROM php:7.3-cli + +RUN docker-php-ext-install mysqli +RUN docker-php-ext-install pdo pdo_mysql + +ADD ./ /var/www + +RUN chmod uog+rwx /var/www/storage/logs + +WORKDIR /var/www + +CMD ["php", "artisan", "queue:work"] \ No newline at end of file diff --git a/Dockerfile b/Dockerfile-web similarity index 100% rename from Dockerfile rename to Dockerfile-web diff --git a/app/Http/Controllers/GUI/AdminController.php b/app/Http/Controllers/GUI/AdminController.php index 9b4cdf0..76aff0d 100644 --- a/app/Http/Controllers/GUI/AdminController.php +++ b/app/Http/Controllers/GUI/AdminController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\GUI; use App\Exceptions\HTTPException; use App\Http\Controllers\Controller; use App\Http\Resources\oAuth\AccessToken; +use App\Jobs\Mails\ValidateMailAddressJob; use App\Models\App; use App\Models\Invite; use App\Models\Mail; @@ -42,6 +43,16 @@ class AdminController extends Controller $settings = Setting::query()->get("*"); return view('admin/settings_list', ["settings"=>$settings]); } + public function resendValidationMail(Request $request) { + if(!Auth::user()->admin) { + throw new HTTPException("Need Admin Access"); + } + $mail = Mail::query()->where("id", "=", $request->input("id"))->firstOrFail(); + + $this->dispatch(new ValidateMailAddressJob($mail)); + + return "OK"; + } public function saveSettings(Request $request) { if(!Auth::user()->admin) { throw new HTTPException("Need Admin Access"); diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php new file mode 100644 index 0000000..46682a2 --- /dev/null +++ b/app/Http/Controllers/StatusController.php @@ -0,0 +1,36 @@ +getPdo(); + + $sth = $pdo->prepare("SELECT * FROM `failed_jobs`"); + $sth->execute(); + $res = $sth->fetchAll(\PDO::FETCH_ASSOC); + if(count($res) > 0 ){ + throw new HTTPException(500, "Failed Jobs"); + } + + + return $response; + + } + + // +} diff --git a/app/Jobs/Mails/ValidateMailAddressJob.php b/app/Jobs/Mails/ValidateMailAddressJob.php index c2a58eb..03f1762 100644 --- a/app/Jobs/Mails/ValidateMailAddressJob.php +++ b/app/Jobs/Mails/ValidateMailAddressJob.php @@ -20,6 +20,8 @@ class ValidateMailAddressJob extends Job $this->mailObject = $mailObject; } + public $tries = 2; + /** * Execute the job. * @@ -45,7 +47,7 @@ class ValidateMailAddressJob extends Job $mail->addBCC($bcc); } $mail->isHTML(true); - $mail->Subject = Setting::getSettingValue("name").' E-Mail validation'; + $mail->Subject = Setting::getSettingValue("name_big").Setting::getSettingValue("name_small").' E-Mail validation'; $mail->Body = 'Hello,
to validate your E-Mail address click on the following link: Activate Account'; $mail->AltBody = 'Hello,\r\nto validate your E-Mail address click on the following link: '.Setting::getSettingValue('url').'/gui/mailValidation/'.$this->mailObject->id.'/'.$this->mailObject->validation_code; $mail->send(); diff --git a/build.sh b/build.sh index 255d074..0faeee2 100644 --- a/build.sh +++ b/build.sh @@ -1,4 +1,7 @@ rm -r -f storage/logs/l* chmod uog+rwx storage/logs -docker build -t docker.keks.cloud/keksaccount/web:latest . -docker push docker.keks.cloud/keksaccount/web:latest \ No newline at end of file +docker build -t docker.keks.cloud/keksaccount/web:latest -f Dockerfile-app . +docker build -t docker.keks.cloud/keksaccount/app:latest -f Dockerfile-app . + +docker push docker.keks.cloud/keksaccount/web:latest +docker push docker.keks.cloud/keksaccount/app:latest diff --git a/database/migrations/2019_07_10_143516_create_jobs_table.php b/database/migrations/2019_07_10_143516_create_jobs_table.php new file mode 100644 index 0000000..58d7715 --- /dev/null +++ b/database/migrations/2019_07_10_143516_create_jobs_table.php @@ -0,0 +1,36 @@ +bigIncrements('id'); + $table->string('queue')->index(); + $table->longText('payload'); + $table->unsignedTinyInteger('attempts'); + $table->unsignedInteger('reserved_at')->nullable(); + $table->unsignedInteger('available_at'); + $table->unsignedInteger('created_at'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('jobs'); + } +} diff --git a/database/migrations/2019_07_10_143549_create_failed_jobs_table.php b/database/migrations/2019_07_10_143549_create_failed_jobs_table.php new file mode 100644 index 0000000..d432dff --- /dev/null +++ b/database/migrations/2019_07_10_143549_create_failed_jobs_table.php @@ -0,0 +1,35 @@ +bigIncrements('id'); + $table->text('connection'); + $table->text('queue'); + $table->longText('payload'); + $table->longText('exception'); + $table->timestamp('failed_at')->useCurrent(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('failed_jobs'); + } +} diff --git a/docker-compose.yml b/docker-compose.yml index ea60be1..85b6ff6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,15 +1,23 @@ version: '3' services: webapp: - build: ./ + build: + context: ./ + dockerfile: Dockerfile-web volumes: - ./:/var/www ports: - 8000:80 + app: + build: + context: ./ + dockerfile: Dockerfile-app + volumes: + - ./:/var/www mysql: image: mysql:5.7 ports: - - 3366:3306 + - 3306:3306 environment: MYSQL_ROOT_PASSWORD: example MYSQL_DATABASE: oauth diff --git a/kube.yml b/kube.yml deleted file mode 100644 index 374cd3c..0000000 --- a/kube.yml +++ /dev/null @@ -1,147 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: env-keksaccount-web - namespace: keksaccount -data: - APP_DEBUG: "false" - DB_CONNECTION: "mysql" - DB_HOST: "mysql" - DB_PORT: "3306" - DB_PORT: "oauth" - DB_USERNAME: "oauth" - DB_PASSWORD: "oauth" ---- -apiVersion: v1 -kind: Secret -metadata: - name: secret-keksaccount-mysql - namespace: keksaccount -type: Opaque -data: - MYSQL_ROOT_PASSWORD: dGlmaW1hZG9ja2Vy - MYSQL_DATABASE: b2F1dGg= - MYSQL_USER: b2F1dGg= - MYSQL_PASSWORD: b2F1dGg= ---- -apiVersion: extensions/v1beta1 -kind: Deployment -metadata: - name: keksaccount - namespace: keksaccount -spec: - replicas: 1 - template: - metadata: - labels: - app: keksaccount - spec: - containers: - - name: web - image: docker.keks.cloud/keksaccount/web:latest - ports: - - containerPort: 80 - envFrom: - - configMapRef: - name: env-keksaccount-web - imagePullSecrets: - - name: docker-keks-cloud - ---- -apiVersion: v1 -kind: Service -metadata: - annotations: - field.cattle.io/targetWorkloadIds: '["deployment:keksaccount:keksaccount"]' - name: ingress-keksaccount - namespace: keksaccount -spec: - ports: - - port: 80 - protocol: TCP - targetPort: 80 - type: ClusterIP -status: - loadBalancer: {} ---- -apiVersion: extensions/v1beta1 -kind: Deployment -metadata: - name: mysql - namespace: keksaccount -spec: - replicas: 1 - template: - metadata: - labels: - app: mysql - spec: - containers: - - name: mysql - image: mysql:5.6 - ports: - - containerPort: 3306 - envFrom: - - secretRef: - name: secret-keksaccount-mysql - volumeMounts: - - mountPath: /var/lib/mysql - name: mysql - volumes: - - name: mysql - persistentVolumeClaim: - claimName: mysql ---- -apiVersion: v1 -kind: Service -metadata: - annotations: - field.cattle.io/targetWorkloadIds: '["deployment:keksaccount:mysql"]' - name: mysql - namespace: keksaccount -spec: - ports: - - port: 3306 - protocol: TCP - targetPort: 3306 - type: ClusterIP -status: - loadBalancer: {} ---- -apiVersion: certmanager.k8s.io/v1alpha1 -kind: Certificate -metadata: - name: account.keks.cloud - namespace: keksaccount -spec: - secretName: account-keks-cloud-tls - acme: - config: - - dns01: - provider: cf-dns - domains: - - 'account.keks.cloud' - commonName: 'account.keks.cloud' - dnsNames: - - account.keks.cloud - issuerRef: - kind: ClusterIssuer - name: letsencrypt-prod - ---- -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: keksaccount - namespace: keksaccount -spec: - rules: - - host: account.keks.cloud - http: - paths: - - backend: - serviceName: ingress-keksaccount - servicePort: 80 - path: / - tls: - - secretName: account-keks-cloud-tls \ No newline at end of file diff --git a/resources/views/admin/user_details.php b/resources/views/admin/user_details.php index 1e0ff3c..756f9da 100644 --- a/resources/views/admin/user_details.php +++ b/resources/views/admin/user_details.php @@ -44,6 +44,7 @@ if($mail->status == "waiting") { echo 'Aktivieren'; } + echo 'Resend Validation Mail'; ?> diff --git a/routes/test b/routes/test new file mode 100644 index 0000000..166cf53 --- /dev/null +++ b/routes/test @@ -0,0 +1 @@ +curl 'http://localhost:8000/api/v1/user/register' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://localhost:8000/gui/register?invite=KrAWOlMaJOGEWNMrN6jO' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Cookie: DOKU_PREFS=ext_enabled%231%23ext_disabled%231%23ext_updatable%231; DokuWiki=457d4e3dd81951e4a220b1a968daf6c5; DW68700bfd16c2027de7de74a5a8202a6f=c29lcmVu%7C0%7CSlpEYBEUM3HZF6SzyKe80M6kD3Lc%2Bby2VPiX6AYVcd8%3D; PHPSESSID=2f124bd5695f0521bc330c912bfd1a30' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' --data 'invite=KrAWOlMaJOGEWNMrN6jO&username=registerfailed&password=gelnhausen&mail=soeren%40siegismund-poschmann.de' \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 9a5b046..fb58afe 100644 --- a/routes/web.php +++ b/routes/web.php @@ -73,6 +73,7 @@ $router->post("api/v1/user/register", ['uses' => 'API\UserController@register']) $router->get("api/v1/user/captcha", ['uses' => 'API\UserController@reCAPTCHA']); $router->get("api/v1/user/invites", ['uses' => 'API\UserController@getInviteCodeInfo']);*/ $router->get("api/v1/server/settings", ["uses" => "API\ServerController@getSettings"]); +$router->get("status/check", ["uses" => "StatusController@check"]); $router->group(['prefix' => 'gui', 'middleware' => 'gui'], function () use ($router) { $router->get('/register', ['uses' => 'GUI\AccountController@registerView']); @@ -110,6 +111,7 @@ $router->group(['prefix' => 'gui', 'middleware' => 'gui'], function () use ($rou $router->get("/admin/users", ["uses" => 'GUI\AdminController@listUser']); $router->get("/admin/users/{id}", ["uses" => 'GUI\AdminController@userDetails']); $router->post("/admin/users/{id}", ["uses" => 'GUI\AdminController@saveUserDetails']); + $router->get("/admin/resendInviteMail", ["uses" => 'GUI\AdminController@resendValidationMail']);