diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-04 08:46:09 +0300 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-04 08:46:09 +0300 |
| commit | 8df89ce39d2acf5b23ee15241060bd9dd6551620 (patch) | |
| tree | 06eded98dc24022ce2e5ccfb43d07696427fb5fb | |
| parent | 0d317dc0cfe6ae2b6b62d711b7ae67e63555235f (diff) | |
| download | classroom-8df89ce39d2acf5b23ee15241060bd9dd6551620.tar.gz classroom-8df89ce39d2acf5b23ee15241060bd9dd6551620.tar.bz2 classroom-8df89ce39d2acf5b23ee15241060bd9dd6551620.zip | |
database migrated; privileges table has an included(-privileges) field
| -rw-r--r-- | Dockerfile | 13 | ||||
| -rw-r--r-- | composer.lock | 661 | ||||
| -rw-r--r-- | docker/bin/docker-entrypoint.sh | 6 | ||||
| -rw-r--r-- | html/app/config/app_constants.php | 11 | ||||
| -rw-r--r-- | html/app/controllers/Auth.php | 1 | ||||
| -rw-r--r-- | html/app/extends/Send_mail.php | 29 | ||||
| -rw-r--r-- | html/app/models/admin/User_model.php | 40 | ||||
| -rw-r--r-- | html/app/routes/frontend.php | 7 | ||||
| -rw-r--r-- | html/app/views/user/registration.php (renamed from html/app/views/user/register.php) | 2 |
9 files changed, 751 insertions, 19 deletions
@@ -4,7 +4,7 @@ FROM php:8.1-apache as builder ARG MODE="debug" -# mailhog configuration +# mailhog (fake mail) configuration # ------------------------------------------------------------------------------ # RUN apt-get update &&\ # apt-get install --no-install-recommends --assume-yes --quiet ca-certificates curl git &&\ @@ -16,6 +16,17 @@ ARG MODE="debug" # RUN echo 'sendmail_path = /usr/bin/mhsendmail --smtp-addr mailhog:1025' > /usr/local/etc/php/php.ini +# msmtp (real mail) configuration +# ------------------------------------------------------------------------------ +# RUN apt-get update && apt-get install -y msmtp && apt-get clean && rm -r /var/lib/apt/lists/* +# configure sendmail +# RUN { \ +# echo "php_admin_value[sendmail_path] = $(which msmtp) -ti "; \ +# } >> /usr/local/etc/php-fpm.d/www.conf + + + + # setup apache # ------------------------------------------------------------------------------ diff --git a/composer.lock b/composer.lock index 5810b75..b7c2f98 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,397 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "33cad13092641f81b77ea1ff6e1ca5db", + "content-hash": "b3dacac13073b78ee8cc0715dbe88e27", "packages": [ { + "name": "guzzlehttp/guzzle", + "version": "7.5.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b50a2a1251152e43f6a37f0fa053e730a67d25ba", + "reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.5", + "guzzlehttp/psr7": "^1.9 || ^2.4", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.1", + "ext-curl": "*", + "php-http/client-integration-tests": "^3.0", + "phpunit/phpunit": "^8.5.29 || ^9.5.23", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + }, + "branch-alias": { + "dev-master": "7.5-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.5.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "time": "2022-08-28T15:39:27+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "1.5.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "b94b2807d85443f9719887892882d0329d1e2598" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/b94b2807d85443f9719887892882d0329d1e2598", + "reference": "b94b2807d85443f9719887892882d0329d1e2598", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "symfony/phpunit-bridge": "^4.4 || ^5.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/1.5.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2022-08-28T14:55:35+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.4.4", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf", + "reference": "3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.1", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.29 || ^9.5.23" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + }, + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.4.4" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2023-03-09T13:19:02+00:00" + }, + { + "name": "mailjet/mailjet-apiv3-php", + "version": "v1.5.8", + "source": { + "type": "git", + "url": "https://github.com/mailjet/mailjet-apiv3-php.git", + "reference": "747518ce0eebf64d27e9903441a255c85472a139" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mailjet/mailjet-apiv3-php/zipball/747518ce0eebf64d27e9903441a255c85472a139", + "reference": "747518ce0eebf64d27e9903441a255c85472a139", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/guzzle": "^7.4.4", + "php": "^7.2|^8.0", + "psr/http-client": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^1.4", + "php-coveralls/php-coveralls": "^2.0", + "phpunit/phpunit": "^8|^9" + }, + "type": "library", + "autoload": { + "psr-0": { + "Mailjet": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mailjet", + "email": "dev@mailjet.com", + "homepage": "https://dev.mailjet.com" + } + ], + "description": "PHP wrapper for the Mailjet API", + "homepage": "https://github.com/mailjet/mailjet-apiv3-php/", + "keywords": [ + "Mailjet", + "api", + "email", + "php", + "v3" + ], + "support": { + "issues": "https://github.com/mailjet/mailjet-apiv3-php/issues", + "source": "https://github.com/mailjet/mailjet-apiv3-php/tree/v1.5.8" + }, + "time": "2022-10-15T16:24:08+00:00" + }, + { "name": "phpmailer/phpmailer", "version": "v6.8.0", "source": { @@ -85,6 +473,277 @@ } ], "time": "2023-03-06T14:43:22+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client/tree/master" + }, + "time": "2020-06-29T06:28:15+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory/tree/master" + }, + "time": "2019-04-30T12:38:16+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/master" + }, + "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.2.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", + "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.3-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.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": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-03-01T10:25:55+00:00" } ], "packages-dev": [], diff --git a/docker/bin/docker-entrypoint.sh b/docker/bin/docker-entrypoint.sh index 236c4fb..ee396d3 100644 --- a/docker/bin/docker-entrypoint.sh +++ b/docker/bin/docker-entrypoint.sh @@ -1,19 +1,25 @@ #! /bin/sh +# setup writable directories +# ------------------------------------------------------------------------------ # grand to 'cache' directory writable permissions # set file-cache directory to apache's user ownership chmod -R 755 /var/www/html/cache chown -R www-data:www-data /var/www/html/cache # copy composer.json to 'www'; then prepare auutoloading +# ------------------------------------------------------------------------------ cp /var/www/docker/config/composer-naked.json /var/www/composer.json (cd /var/www ; composer update) (cd /var/www ; composer dump-autoload) + ### set -ex ### ### /cloud_sql_proxy -instances=pythia-251711:europe-west4:pythia-db-eu -dir=/cloudsql -credential_file=/cloudsqlproxy.json & ### sleep 3 +# start apache +# ------------------------------------------------------------------------------ # End with running the original command exec /usr/sbin/apache2ctl -D FOREGROUND
\ No newline at end of file diff --git a/html/app/config/app_constants.php b/html/app/config/app_constants.php index 4ddf7ac..5a2c9b3 100644 --- a/html/app/config/app_constants.php +++ b/html/app/config/app_constants.php @@ -32,10 +32,15 @@ define('MAIL_PORT', $env['MAIL_PORT']); define('MAIL_USERNAME', $env['MAIL_USERNAME']); define('MAIL_PASSWORD', $env['MAIL_PASSWORD']); define('MAIL_ENCRYPTION', $env['MAIL_ENCRYPTION']); +define('MAIL_FROM_NAME', $env['MAIL_FROM_NAME']); define('NO_REPLY_EMAIL', $env['NO_REPLY_EMAIL']); define('REPLY_TO_EMAIL', $env['REPLY_TO_EMAIL']); - +// mailjet setup +// --- -- -- - - - +define('MJ_API_KEY', $env['MJ_API_KEY']); +define('MJ_SECRET_KEY', $env['MJ_SECRET_KEY']); +define('MJ_SMTP', $env['MJ_SMTP']); // DEFAULT VALUES ////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- @@ -44,8 +49,8 @@ define('REPLY_TO_EMAIL', $env['REPLY_TO_EMAIL']); // (array of privilege aliases) // --- -- -- - - - define('DEFAULT_PRIVILEGES', [ - 'e.1', // economics, level 1 - 'p.1' // programming. level 1 + 1, // economics, level 1 + 5 // programming. level 1 ]); diff --git a/html/app/controllers/Auth.php b/html/app/controllers/Auth.php index de850fe..50f8fe4 100644 --- a/html/app/controllers/Auth.php +++ b/html/app/controllers/Auth.php @@ -9,6 +9,7 @@ use app\extends\Classroom_manager; use app\models\admin\User_model; use app\extends\Send_mail; +use app\extends\Mail_jet; /** class Auth diff --git a/html/app/extends/Send_mail.php b/html/app/extends/Send_mail.php index c3ecb66..7dbb50a 100644 --- a/html/app/extends/Send_mail.php +++ b/html/app/extends/Send_mail.php @@ -17,11 +17,11 @@ class Send_mail $mail->SMTPDebug = 3; $mail->IsSMTP(); $mail->Host = MAIL_HOST; - $mail->SMPTAuth = true; + $mail->SMPTAuth = false; $mail->SMTPSecure = MAIL_ENCRYPTION; // $mail->Protocol = 'mail'; - // $mail->Mailer = MAIL_MAILER; + $mail->Mailer = MAIL_MAILER; $mail->Port = MAIL_PORT; $mail->Username = MAIL_USERNAME; $mail->Password = MAIL_PASSWORD; @@ -61,10 +61,9 @@ class Send_mail // It's important not to use the submitter's address as the from address as it's forgery, // which will cause your messages to fail SPF checks. // Use an address in your own domain as the from address, put the submitter's address in a reply-to - $mail->setFrom(NO_REPLY_EMAIL, SITE_TITLE); + $mail->setFrom(NO_REPLY_EMAIL, MAIL_FROM_NAME); $mail->addAddress($envelope['email'], $envelope['name']); - $mail->addReplyTo(REPLY_TO_EMAIL, SITE_TITLE); - $mail->AddBCC("piipiis@gmail.com", "tester"); // notifiation email while testing + $mail->addReplyTo(REPLY_TO_EMAIL, MAIL_FROM_NAME); $mail->Subject = 'Εγγραφή στο Classroom'; $mail->Body = "Χαίρετε,<br> το παρόν αυτοποιημένο email σάς έχει σταλεί γιατί έχει γίνει αίτημα εγγραφής σας στο Classroom.<br> @@ -87,6 +86,10 @@ class Send_mail } } + + + + } @@ -153,5 +156,21 @@ Log event to Email * rU8WEmcHsRcEQaH * rU8WEmcHsRcEQaH * + * mailjet + * piipiis@g + * EN6Xg8!99ZTKaYp7 + * + * + * sendGrid + * piipiis + * EN6Xg899ZTKU8WEmcHsR54321 + * + * + * time4vps... + * https://community.time4vps.com/discussion/75/are-any-ports-blocked-by-time4vps + * + * test activation code: + * ca42d68cfba5fbbafeacc010b8e3a551 + * */
\ No newline at end of file diff --git a/html/app/models/admin/User_model.php b/html/app/models/admin/User_model.php index bfed5c5..187da2d 100644 --- a/html/app/models/admin/User_model.php +++ b/html/app/models/admin/User_model.php @@ -129,7 +129,7 @@ class User_model * @return $activation_code * */ - public static function registerUser($data, $password, $privileges = ['ec.1', 'pr.1']) + public static function registerUser($data, $password, $privileges = DEFAULT_PRIVILEGES) { $required_fields = [ 'name', @@ -174,7 +174,7 @@ class User_model )->lastInsertID(); // set default privileges - // self::set_user_privileges($privileges); + // self::set_user_privileges($new_user_id, $privileges); // update history History::trackUserAccess($new_user_id, TRACK_ACCOUNT, 'Create User Account'); @@ -188,26 +188,54 @@ class User_model } - public static fuunction activate($ticket) + public static function activate($ticket) { $user = Registry::use('database')->query( "SELECT * FROM user WHERE activation = :ticket", - [ 'ticket' => $ticket] + [ 'ticket' => $ticket ] )->getFirst(); // if no user with this activation code, return false if ($user === false) return false; + // remove activation code from user record Registry::use('database')->runQuery( - "UPDATE user SET activated = 1 WHERE activation = :ticket", - [ 'ticket' => $ticket] + "UPDATE user + SET activated = 1, `activation` = NULL + WHERE activation = :ticket", + [ 'ticket' => $ticket ] ); + // update history + History::trackUserAccess($new_user_id, TRACK_ACCOUNT, 'User Account Activated'); + return true; } + /** set_user_privileges + * + * @param $user_id (int) + * @param $privileges (array) + */ + public static function set_user_privileges($user_id, $privileges) + { + + foreach($privileges as $pri) { + Registry::use('database')->runQuery( + "INSERT INTO user_privilege (user_id, privilege_id) + VALUES (:user, :privilege)", + [ + ':user' => $user_id, + ':privilege' => $pri + ] + ); + } + + return true; + } + /** inherited privileges * * list of all inhereted (sub-)privileges diff --git a/html/app/routes/frontend.php b/html/app/routes/frontend.php index ca91f7b..e602e87 100644 --- a/html/app/routes/frontend.php +++ b/html/app/routes/frontend.php @@ -2,6 +2,7 @@ use app\controllers\Resolve; use app\controllers\Product; +use app\controllers\Auth; use app\controllers\Classroom_user; // Home/Welcome @@ -38,7 +39,8 @@ Route::notFound( function() { Route::add('/login', function() { Render::view('user/login'); }); -Route::add('/register', function() { Render::view('user/register'); }); +Route::add('/registration', function() { Render::view('user/registration'); }); + @@ -46,10 +48,11 @@ Route::add('/register', function() { Render::view('user/register'); }); // user sends a registration form; Route::add('/account/register', function() { $x = Auth::register(); print_r($x); }, 'post'); - +// user requests activation Route::add('/account/activate', function() { Auth::activate(); } ); + Route::add('/account/reset_password', function() { Auth::reset_password(); } ); diff --git a/html/app/views/user/register.php b/html/app/views/user/registration.php index a5ee116..e3527f0 100644 --- a/html/app/views/user/register.php +++ b/html/app/views/user/registration.php @@ -105,7 +105,7 @@ }; // select action url (add or update) - var request = '/register'; + var request = '/account/register'; // send POST request $.post(request, data) |
