diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..a8addd6
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,6 @@
+[*]
+end_of_line = lf
+insert_final_newline = true
+charset = utf-8
+indent_style = space
+indent_size = 4
diff --git a/README.md b/README.md
index 55250ea..87516ea 100755
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# README #
-A simple webinterface for users. This app uses [`admin_rest`](https://github.com/snowblindroan/mod_admin_rest) module of prosody. So [prosody.im](http://prosody.im) and this module are hard dependencies. The interface allows users
+A simple webinterface for users. This app uses [`admin_rest`](https://github.com/snowblindroan/mod_admin_rest) module of
+prosody. So [prosody.im](http://prosody.im) and this module are hard dependencies. The interface allows users
* to have two step verification (as an alternative to the integrated `register_web` module),
* to delete of their accounts and
@@ -38,7 +39,8 @@ as dependencies.
## Deployment ##
-* Set up a cron job using `php projectRootDir/bin/UsersAwaitingVerificationCleanUpCronJob.php` to clean up users who signed up but did not verify their account periodically.
+* Set up a cron job using `php projectRootDir/bin/UsersAwaitingVerificationCleanUpCronJob.php` to clean up users who
+ signed up but did not verify their account periodically.
* Point your document root to `public/`.
* Example nginx conf:
@@ -75,13 +77,17 @@ You should be able to set a very strict Content-Security-Policy.
* look into Changelog for major changes
## Developers ##
+
* start server with `php -S localhost:8080 -t public public/index.php`
* point browser to [localhost:8080](http://localhost:8080) to have a preview
## Translations ##
-This app uses Symfony Translator. It's bootstraped in `Util\BootstrapHelper` and locales are placed under `data/locale/`. Adjust to your needs or help translating.
+
+This app uses Symfony Translator. It's bootstraped in `Util\BootstrapHelper` and locales are placed under `data/locale/`
+. Adjust to your needs or help translating.
## Changelog ##
+
- 0.3.0.1
- Remove cookie consent as session cookies should be allowed because they provide core functionality
- Adjust `legal.example.md` and add `PHPSESSID`
@@ -120,7 +126,9 @@ This app uses Symfony Translator. It's bootstraped in `Util\BootstrapHelper` and
- added admin notifications
- added possibility for users to delete their account
- added back index page
- - works with mod_admin_rest version [afc42d7](https://github.com/snowblindroan/mod_admin_rest/commit/afc42d70f0aceb2351a1bc786d61e3f4dbdfb948)
-- 0.1:
+ - works with mod_admin_rest
+ version [afc42d7](https://github.com/snowblindroan/mod_admin_rest/commit/afc42d70f0aceb2351a1bc786d61e3f4dbdfb948)
+- 0.1:
- initial release
- - works with mod_admin_rest version [afc42d7](https://github.com/snowblindroan/mod_admin_rest/commit/afc42d70f0aceb2351a1bc786d61e3f4dbdfb948)
\ No newline at end of file
+ - works with mod_admin_rest
+ version [afc42d7](https://github.com/snowblindroan/mod_admin_rest/commit/afc42d70f0aceb2351a1bc786d61e3f4dbdfb948)
diff --git a/composer.json b/composer.json
index 04354eb..215e453 100644
--- a/composer.json
+++ b/composer.json
@@ -1,29 +1,29 @@
{
- "require": {
- "slim/slim": "^3.0",
- "monolog/monolog": "^1.18",
- "slim/twig-view": "^2.1",
- "jralph/twig-markdown": "^2.0",
- "slim/flash": "^0.1.0",
- "wixel/gump": "^1.3",
- "curl/curl": "^1.4",
- "phpmailer/phpmailer": "^5.2",
- "illuminate/database": "~5.2",
- "davedevelopment/phpmig": "^1.2",
- "symfony/translation": "^3.1",
- "symfony/twig-bridge": "^3.1",
- "vlucas/phpdotenv": "^2.3",
- "fabiang/xmpp": "^0.6.1",
- "jeremykendall/slim-auth": "dev-slim-3.x",
- "symfony/yaml": "*"
- },
- "config": {
- "bin-dir": "bin/"
- },
- "autoload": {
- "classmap": [
- "src/",
- "config/"
- ]
- }
+ "require": {
+ "slim/slim": "^3.0",
+ "monolog/monolog": "^1.18",
+ "slim/twig-view": "^2.1",
+ "jralph/twig-markdown": "^2.0",
+ "slim/flash": "^0.1.0",
+ "wixel/gump": "^1.3",
+ "curl/curl": "^1.4",
+ "phpmailer/phpmailer": "^5.2",
+ "illuminate/database": "~5.2",
+ "davedevelopment/phpmig": "^1.2",
+ "symfony/translation": "^3.1",
+ "symfony/twig-bridge": "^3.1",
+ "vlucas/phpdotenv": "^2.3",
+ "fabiang/xmpp": "^0.6.1",
+ "jeremykendall/slim-auth": "dev-slim-3.x",
+ "symfony/yaml": "*"
+ },
+ "config": {
+ "bin-dir": "bin/"
+ },
+ "autoload": {
+ "classmap": [
+ "src/",
+ "config/"
+ ]
+ }
}
diff --git a/config/ACL.php b/config/ACL.php
index 87a4e57..8a80afd 100644
--- a/config/ACL.php
+++ b/config/ACL.php
@@ -27,7 +27,7 @@ class ACL extends \Zend\Permissions\Acl\Acl
'/password',
'/logout',
],
- 'guest' => [
+ 'guest' => [
'/login',
'/signup',
'/verification/{verificationCode}',
@@ -39,9 +39,9 @@ class ACL extends \Zend\Permissions\Acl\Acl
],
];
public static $ACL_DENIES = [
- 'admin' => ['/login', '/signup', '/verification/{verificationCode}'],
- 'member' => ['/login', '/signup', '/verification/{verificationCode}'],
- 'guest' => []
+ 'admin' => ['/login', '/signup', '/verification/{verificationCode}'],
+ 'member' => ['/login', '/signup', '/verification/{verificationCode}'],
+ 'guest' => []
];
public function __construct()
@@ -86,4 +86,4 @@ class ACL extends \Zend\Permissions\Acl\Acl
}
}
}
-}
\ No newline at end of file
+}
diff --git a/config/Config.php b/config/Config.php
index 1badf61..b80cce1 100644
--- a/config/Config.php
+++ b/config/Config.php
@@ -9,7 +9,7 @@ class Config
// no need to change anything here
'db_settings' => [
'driver' => 'sqlite',
- 'database' => __DIR__ . DIRECTORY_SEPARATOR . '..'. DIRECTORY_SEPARATOR .'data'. DIRECTORY_SEPARATOR .'db.sqlite',
+ 'database' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'db.sqlite',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
@@ -21,13 +21,13 @@ class Config
],
'twig_settings' => [
- 'twig_dir' => __DIR__ . DIRECTORY_SEPARATOR . '..'. DIRECTORY_SEPARATOR .'src'. DIRECTORY_SEPARATOR .'View',
+ 'twig_dir' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'View',
'twig_cache_dir' => false,
//'twig_cache_dir' => __DIR__ . DIRECTORY_SEPARATOR . '..'. DIRECTORY_SEPARATOR .'src'. DIRECTORY_SEPARATOR .'cache',
],
'logger_settings' => [
- 'path' => __DIR__ . DIRECTORY_SEPARATOR . '..'. DIRECTORY_SEPARATOR .'log'. DIRECTORY_SEPARATOR .'application.log',
+ 'path' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . 'application.log',
],
];
-}
\ No newline at end of file
+}
diff --git a/config/legal.example.md b/config/legal.example.md
index 7e9f8e7..89ef8a9 100644
--- a/config/legal.example.md
+++ b/config/legal.example.md
@@ -13,21 +13,30 @@ Contact data
## Cookies
-This website uses small files called cookies to help the operator customise your experience. Cookies are small text files that are stored by the browser on your device. They allow websites to store things like user preferences. Functionality might be affected if you disable cookies for this website.
+This website uses small files called cookies to help the operator customise your experience. Cookies are small text
+files that are stored by the browser on your device. They allow websites to store things like user preferences.
+Functionality might be affected if you disable cookies for this website.
-These cookies are essential to the proper functioning of our website and enable you to use its features, such as accessing secure areas of the site. Without these cookies, you will not be able to perform core site functions such as logging in.
+These cookies are essential to the proper functioning of our website and enable you to use its features, such as
+accessing secure areas of the site. Without these cookies, you will not be able to perform core site functions such as
+logging in.
| Cookiename | Provider | Purpose |
|:------------------:|:-----------:|:---------|
| `PHPSESSID` | Provider | Creates a unique session for your device, allowing a platform for login. No personal or device information is collected or stored. If you login, you will be given access to parts of the site for registered members. If you close your browser or end your browser session, this cookie will be deleted automatically. |
## Registration
-Registration: An email is stored (maximal: 7 days, typical: deleted after verification process is completed) and credentials (minimal: stored as long as the account exists, typical: check user JID against well-known spammer patterns) are stored.
+
+Registration: An email is stored (maximal: 7 days, typical: deleted after verification process is completed) and
+credentials (minimal: stored as long as the account exists, typical: check user JID against well-known spammer patterns)
+are stored.
## Log
-Access logs are not stored except for fixing bugs in case of an error or an attack on this service. Logs will be removed once the [log rotates](https://en.wikipedia.org/wiki/Log_rotation) within 7 days.
+
+Access logs are not stored except for fixing bugs in case of an error or an attack on this service. Logs will be removed
+once the [log rotates](https://en.wikipedia.org/wiki/Log_rotation) within 7 days.
# Service
- [What data is processed?](https://wiki.xmpp.org/web/GDPR#Q1.1b_List_what_data_is_processed)
-- [How is data processing done?](https://wiki.xmpp.org/web/GDPR#Q1.1c_List_what_processing_is_done)
\ No newline at end of file
+- [How is data processing done?](https://wiki.xmpp.org/web/GDPR#Q1.1c_List_what_processing_is_done)
diff --git a/config/phpmig.php b/config/phpmig.php
index 75bd9fb..34da97f 100644
--- a/config/phpmig.php
+++ b/config/phpmig.php
@@ -1,6 +1,6 @@
getConnection()->getPdo(), 'migrations');
-$container['phpmig.migrations_template_path'] = __DIR__ . DIRECTORY_SEPARATOR . '..'. DIRECTORY_SEPARATOR .'data'. DIRECTORY_SEPARATOR .'phpmig_template.php';
-$container['phpmig.migrations_path'] = __DIR__ . DIRECTORY_SEPARATOR . '..'. DIRECTORY_SEPARATOR .'data'. DIRECTORY_SEPARATOR .'migrations';
+$container['phpmig.migrations_template_path'] = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'phpmig_template.php';
+$container['phpmig.migrations_path'] = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'migrations';
$container['schema'] = $container['db']->schema();
-return $container;
\ No newline at end of file
+return $container;
diff --git a/data/locale/messages.en.yml b/data/locale/messages.en.yml
index 877f43e..b00611e 100644
--- a/data/locale/messages.en.yml
+++ b/data/locale/messages.en.yml
@@ -1,10 +1,10 @@
# Home
home.title: Home
home.text: |
- Welcome to the free jabber service %server%.
-
-
- Create an account by pressing the "Sign up" button in the navigation bar.
+ Welcome to the free jabber service %server%.
+
+
+ Create an account by pressing the "Sign up" button in the navigation bar.
# Sign up
sign.up.title: Sign Up
@@ -28,19 +28,19 @@ legalmodal.title: Policy
# Verification
verification.mail.subject: "%server%: jabber account verification"
verification.mail.body: |
- Hello %username%,
- you've signed up for a jabber account on %server%.
- In order to complete your registration, verify your email within 7 days by clicking on %verificationLink%.
+ Hello %username%,
+ you've signed up for a jabber account on %server%.
+ In order to complete your registration, verify your email within 7 days by clicking on %verificationLink%.
verification.code.invalid: Verification code %verificationCode% is not valid.
verification.flash.already_in_use_username: "%username% is already in use."
verification.flash.success: Verification successful. You can now sign in to your newly created jabber account %username%@%server%.
verification.flash.unknown_error: Could not process sign up of %username%. Please contact administrator.
verification.mail.success.subject: "%server%: jabber account information"
verification.mail.success.body: |
- Hello %username%,
- you've verified your email address successfully and your jabber account on %server% has been created.
- If you wish to delete your account, use %deleteCode% on the website.
- Keep this mail safe!
+ Hello %username%,
+ you've verified your email address successfully and your jabber account on %server% has been created.
+ If you wish to delete your account, use %deleteCode% on the website.
+ Keep this mail safe!
verification.mail.success.notify.subject: "%server%: user verified their account"
verification.mail.success.notify.body: A user (%email%) verified their account %username%@%server% successfully.
@@ -85,9 +85,9 @@ logout.flash.success: Logged out successfully.
# Cleanup
cleanup.mail.subject: "%server%: jabber account verification expired"
cleanup.mail.body: |
- Hello %username%,
- you've recently signed up for a jabber account on %server% but you did not verify your account within 7 days.
- Your verification code is invalid now.
+ Hello %username%,
+ you've recently signed up for a jabber account on %server% but you did not verify your account within 7 days.
+ Your verification code is invalid now.
# Log
log.internal.application.error: Internal application error.
diff --git a/data/migrations/20160710014947_UsersAwaitingVerificationTable.php b/data/migrations/20160710014947_UsersAwaitingVerificationTable.php
index 841a63a..8cf99ba 100644
--- a/data/migrations/20160710014947_UsersAwaitingVerificationTable.php
+++ b/data/migrations/20160710014947_UsersAwaitingVerificationTable.php
@@ -1,4 +1,5 @@
-db->create($this->tableName, function($table) {
+ $this->db->create($this->tableName, function ($table) {
$table->increments('id');
$table->string('username');
$table->string('email')->unique();
@@ -22,18 +23,18 @@ class UsersAwaitingVerificationTable extends Migration
}
/**
- * Undo the migration
- */
+ * Undo the migration
+ */
public function down()
{
$this->db->dropIfExists($this->tableName);
}
/**
- * Init the migration
- */
+ * Init the migration
+ */
public function init()
{
$this->db = $this->container['schema'];
}
-}
\ No newline at end of file
+}
diff --git a/data/migrations/20160710194830_UsersRegisteredTable.php b/data/migrations/20160710194830_UsersRegisteredTable.php
index fb6aee5..24634cc 100644
--- a/data/migrations/20160710194830_UsersRegisteredTable.php
+++ b/data/migrations/20160710194830_UsersRegisteredTable.php
@@ -1,4 +1,5 @@
-db->create($this->tableName, function($table) {
+ $this->db->create($this->tableName, function ($table) {
$table->string('username')->unique()->primary();
$table->string('delete_code', 64);
});
}
/**
- * Undo the migration
- */
+ * Undo the migration
+ */
public function down()
{
$this->db->dropIfExists($this->tableName);
}
/**
- * Init the migration
- */
+ * Init the migration
+ */
public function init()
{
$this->db = $this->container['schema'];
}
-}
\ No newline at end of file
+}
diff --git a/data/phpmig_template.php b/data/phpmig_template.php
index 5001b24..ab68b41 100644
--- a/data/phpmig_template.php
+++ b/data/phpmig_template.php
@@ -1,35 +1,35 @@
-= "
+= "
use Phpmig\Migration\Migration;
class = $className ?> extends Migration
{
- public $tableName = ''; // Table name
- public $db;
+public $tableName = ''; // Table name
+public $db;
- /**
- * Do the migration
- */
- public function up()
- {
- $this->db->create($this->tableName, function($table) {
- $table->timestamps();
- });
- }
+/**
+* Do the migration
+*/
+public function up()
+{
+$this->db->create($this->tableName, function($table) {
+$table->timestamps();
+});
+}
- /**
- * Undo the migration
- */
- public function down()
- {
- $this->db->dropIfExists($this->tableName);
- }
+/**
+* Undo the migration
+*/
+public function down()
+{
+$this->db->dropIfExists($this->tableName);
+}
- /**
- * Init the migration
- */
- public function init()
- {
- $this->db = $this->container['schema'];
- }
-}
\ No newline at end of file
+/**
+* Init the migration
+*/
+public function init()
+{
+$this->db = $this->container['schema'];
+}
+}
diff --git a/src/Control/Actions/DeleteAction.php b/src/Control/Actions/DeleteAction.php
index 36886fe..8a7f801 100644
--- a/src/Control/Actions/DeleteAction.php
+++ b/src/Control/Actions/DeleteAction.php
@@ -32,12 +32,12 @@ final class DeleteAction
// Form validation
$validator = new ValidationHelper();
$validator->filter_rules([
- 'username' => 'trim|sanitize_string',
- 'delete_code' => 'trim|sanitize_string',
+ 'username' => 'trim|sanitize_string',
+ 'delete_code' => 'trim|sanitize_string',
]);
$validator->validation_rules([
- 'username' => 'required|alpha_numeric|max_len,64|min_len,3',
- 'delete_code' => 'required|exact_len,64',
+ 'username' => 'required|alpha_numeric|max_len,64|min_len,3',
+ 'delete_code' => 'required|exact_len,64',
]);
if (!$validator->run($body)) {
$validator->addErrorsToFlashMessage($this->flash);
@@ -77,9 +77,9 @@ final class DeleteAction
// render GET
$this->view->render($response, 'delete.twig', [
- 'title' => $this->translator->trans('delete.title'),
+ 'title' => $this->translator->trans('delete.title'),
]);
return $response;
}
-}
\ No newline at end of file
+}
diff --git a/src/Control/Actions/ForbiddenAction.php b/src/Control/Actions/ForbiddenAction.php
index 772ac24..855d499 100644
--- a/src/Control/Actions/ForbiddenAction.php
+++ b/src/Control/Actions/ForbiddenAction.php
@@ -1,10 +1,10 @@
view->render($response, 'error.twig', [
- 'title' => $this->translator->trans('error.403.title'),
- 'content' => $this->translator->trans('error.403.content')
+ 'title' => $this->translator->trans('error.403.title'),
+ 'content' => $this->translator->trans('error.403.content')
]);
}
-}
\ No newline at end of file
+}
diff --git a/src/Control/Actions/HomeAction.php b/src/Control/Actions/HomeAction.php
index 15eeb66..00228aa 100644
--- a/src/Control/Actions/HomeAction.php
+++ b/src/Control/Actions/HomeAction.php
@@ -1,10 +1,10 @@
view->render($response, 'home.twig', [
- 'title' => $this->translator->trans('home.title'),
- 'content' => $this->translator->trans('home.text', ['%server%' => getenv('site_xmpp_server_displayname')])
+ 'title' => $this->translator->trans('home.title'),
+ 'content' => $this->translator->trans('home.text', ['%server%' => getenv('site_xmpp_server_displayname')])
]);
}
-}
\ No newline at end of file
+}
diff --git a/src/Control/Actions/InternalApplicationErrorAction.php b/src/Control/Actions/InternalApplicationErrorAction.php
index a1b8402..2564064 100644
--- a/src/Control/Actions/InternalApplicationErrorAction.php
+++ b/src/Control/Actions/InternalApplicationErrorAction.php
@@ -1,10 +1,10 @@
view->render($response, 'error.twig', [
- 'title' => $this->translator->trans('error.500.title'),
- 'content' => $this->translator->trans('error.500.content')
+ 'title' => $this->translator->trans('error.500.title'),
+ 'content' => $this->translator->trans('error.500.content')
]);
}
-}
\ No newline at end of file
+}
diff --git a/src/Control/Actions/LoginAction.php b/src/Control/Actions/LoginAction.php
index 87870cd..7497646 100644
--- a/src/Control/Actions/LoginAction.php
+++ b/src/Control/Actions/LoginAction.php
@@ -1,11 +1,11 @@
filter_rules([
- 'username' => 'trim|sanitize_string',
+ 'username' => 'trim|sanitize_string',
]);
$validator->validation_rules([
- 'username' => 'required|alpha_numeric|max_len,64|min_len,3',
- 'password' => 'required|max_len,255|min_len,8',
+ 'username' => 'required|alpha_numeric|max_len,64|min_len,3',
+ 'password' => 'required|max_len,255|min_len,8',
]);
if (!$validator->run($body)) {
$validator->addErrorsToFlashMessage($this->flash);
@@ -70,7 +70,7 @@ final class LoginAction
// render GET
$this->view->render($response, 'login.twig', [
- 'title' => $this->translator->trans('login.title'),
+ 'title' => $this->translator->trans('login.title'),
]);
}
-}
\ No newline at end of file
+}
diff --git a/src/Control/Actions/LogoutAction.php b/src/Control/Actions/LogoutAction.php
index fcbfa7d..28507bd 100644
--- a/src/Control/Actions/LogoutAction.php
+++ b/src/Control/Actions/LogoutAction.php
@@ -1,11 +1,11 @@
auth->logout();
return $response->withRedirect('login');
}
-}
\ No newline at end of file
+}
diff --git a/src/Control/Actions/NotAuthorizedAction.php b/src/Control/Actions/NotAuthorizedAction.php
index a38317f..246b7eb 100644
--- a/src/Control/Actions/NotAuthorizedAction.php
+++ b/src/Control/Actions/NotAuthorizedAction.php
@@ -1,10 +1,10 @@
view->render($response, 'error.twig', [
- 'title' => $this->translator->trans('error.401.title'),
- 'content' => $this->translator->trans('error.401.content')
+ 'title' => $this->translator->trans('error.401.title'),
+ 'content' => $this->translator->trans('error.401.content')
]);
}
-}
\ No newline at end of file
+}
diff --git a/src/Control/Actions/NotFoundAction.php b/src/Control/Actions/NotFoundAction.php
index 9bb8138..9639a3c 100644
--- a/src/Control/Actions/NotFoundAction.php
+++ b/src/Control/Actions/NotFoundAction.php
@@ -1,10 +1,10 @@
view->render($response, 'error.twig', [
- 'title' => $this->translator->trans('error.404.title'),
- 'content' => $this->translator->trans('error.404.content')
+ 'title' => $this->translator->trans('error.404.title'),
+ 'content' => $this->translator->trans('error.404.content')
]);
}
-}
\ No newline at end of file
+}
diff --git a/src/Control/Actions/PasswordAction.php b/src/Control/Actions/PasswordAction.php
index 6bf8ce7..8666aae 100644
--- a/src/Control/Actions/PasswordAction.php
+++ b/src/Control/Actions/PasswordAction.php
@@ -35,7 +35,7 @@ final class PasswordAction
// Form validation
$validator = new ValidationHelper();
$validator->validation_rules([
- 'password' => 'required|max_len,255|min_len,8',
+ 'password' => 'required|max_len,255|min_len,8',
'password_confirmation' => 'required|max_len,255|min_len,8',
]);
if (!$validator->run($body)) {
@@ -75,9 +75,9 @@ final class PasswordAction
// render GET
$this->view->render($response, 'password.twig', [
- 'title' => $this->translator->trans('password.title'),
+ 'title' => $this->translator->trans('password.title'),
]);
return $response;
}
-}
\ No newline at end of file
+}
diff --git a/src/Control/Actions/SignUpAction.php b/src/Control/Actions/SignUpAction.php
index 8bda0bf..f1e2dba 100644
--- a/src/Control/Actions/SignUpAction.php
+++ b/src/Control/Actions/SignUpAction.php
@@ -1,12 +1,12 @@
filter_rules([
- 'username' => 'trim|sanitize_string',
- 'email' => 'trim|sanitize_email',
+ 'username' => 'trim|sanitize_string',
+ 'email' => 'trim|sanitize_email',
]);
$validator->validation_rules([
- 'username' => 'required|alpha_numeric|max_len,64|min_len,3',
- 'email' => 'required|valid_email|max_len,64|min_len,5',
- 'password' => 'required|max_len,255|min_len,8',
- 'legal' => 'required|boolean'
+ 'username' => 'required|alpha_numeric|max_len,64|min_len,3',
+ 'email' => 'required|valid_email|max_len,64|min_len,5',
+ 'password' => 'required|max_len,255|min_len,8',
+ 'legal' => 'required|boolean'
]);
if (!$validator->run($body)) {
$validator->addErrorsToFlashMessage($this->flash);
@@ -109,7 +109,7 @@ final class SignUpAction
$verificationLink = $request->getUri()->getScheme();
$verificationLink .= '://';
$verificationLink .= $request->getUri()->getHost();
- $verificationLink .= (!empty($p = $request->getUri()->getPort()) ? ':' .$p : '');
+ $verificationLink .= (!empty($p = $request->getUri()->getPort()) ? ':' . $p : '');
$verificationLink .= $this->router->pathFor('verification', ['verificationCode' => $userAwaiting->verification_code]);
$mailer->Subject = $this->translator->trans('verification.mail.subject', ['%server%' => getenv('site_xmpp_server_displayname')]);
@@ -132,10 +132,10 @@ final class SignUpAction
// render GET
$this->view->render($response, 'signup.twig', [
- 'title' => $this->translator->trans('sign.up.title'),
+ 'title' => $this->translator->trans('sign.up.title'),
'legal' => $legalFileContent
]);
return $response;
}
-}
\ No newline at end of file
+}
diff --git a/src/Model/UserAwaitingVerification.php b/src/Model/UserAwaitingVerification.php
index f682af2..4239082 100644
--- a/src/Model/UserAwaitingVerification.php
+++ b/src/Model/UserAwaitingVerification.php
@@ -1,7 +1,8 @@
delete_code = hash('sha256', (time() . $this->username . rand()));
}
-}
\ No newline at end of file
+}
diff --git a/src/Util/ValidationHelper.php b/src/Util/ValidationHelper.php
index 7030532..d5ae80e 100644
--- a/src/Util/ValidationHelper.php
+++ b/src/Util/ValidationHelper.php
@@ -13,59 +13,110 @@ class ValidationHelper extends GUMP
$this->translator = BootstrapHelper::bootTranslator();
}
- /** Validates if $field content is equal to $param
- * @param $field
- * @param $input
- * @param $param
- * @return bool
+ /**
+ * Perform data validation against the provided ruleset
+ *
+ * Arrays as FIELDS are added here as a custom feature
+ *
+ * @access public
+ * @param mixed $input
+ * @param array $ruleset
+ * @return mixed
+ * @throws \Exception
*/
- protected function validate_equals($field, $input, $param)
+ public function validate(array $input, array $ruleset)
{
- $err = [
- 'field' => $field,
- 'value' => $input[$field],
- 'rule' => __FUNCTION__,
- 'param' => $param,
- ];
+ $this->errors = [];
- if (!isset($input[$field]) || empty($input[$field]) || empty($param) || !isset($param)) {
- return $err;
+ foreach ($ruleset as $field => $rules) {
+ #if(!array_key_exists($field, $input))
+ #{
+ # continue;
+ #}
+
+ $rules = explode('|', $rules);
+
+ if (in_array("required", $rules) || (isset($input[$field]) && (is_array($input[$field]) || trim($input[$field]) != ''))) {
+
+ foreach ($rules as $rule) {
+ $method = NULL;
+ $param = NULL;
+
+ if (strstr($rule, ',') !== false) // has params
+ {
+ $rule = explode(',', $rule);
+ $method = 'validate_' . $rule[0];
+ $param = $rule[1];
+ $rule = $rule[0];
+ } else {
+ $method = 'validate_' . $rule;
+ }
+
+ // array required
+ if ($rule === "required" && !isset($input[$field])) {
+ $result = $this->$method($field, $input, $param);
+ $this->errors[] = $result;
+
+ return;
+ }
+
+ if (is_callable([$this, $method])) {
+ $result = $this->$method($field, $input, $param);
+
+ if (is_array($result)) // Validation Failed
+ {
+ $this->errors[] = $result;
+
+ return $this->errors;
+ }
+ } else {
+ if (isset(self::$validation_methods[$rule])) {
+ if (isset($input[$field])) {
+ $result = call_user_func(self::$validation_methods[$rule], $field, $input, $param);
+
+ $result = $this->$method($field, $input, $param);
+
+ if (is_array($result)) // Validation Failed
+ {
+ $this->errors[] = $result;
+
+ return $this->errors;
+ }
+ }
+ } else {
+ throw new \Exception("Validator method '$method' does not exist.");
+ }
+ }
+ }
+ }
}
- if ($input[$field] != $param || $input[$field] !== $param) {
- return $err;
- }
+ return (count($this->errors) > 0) ? $this->errors : true;
+ }
- return true;
+ public function filter_upper($value, $param = NULL)
+ {
+ return strtoupper($value);
+ }
+
+ public function filter_lower($value, $param = NULL)
+ {
+ return strtolower($value);
}
/**
- * Validates if array has min size, defaults to size = 1
- * @param $field
- * @param $input
- * @param null $param
- * @return array|bool
+ * Converts all error array into a single string
+ * @return void
*/
- protected function validate_set_min_len($field, $input, $param = NULL)
+ public function addErrorsToFlashMessage($flash)
{
+ $errors = $this->get_errors_array(true);
- $err = [
- 'field' => $field,
- 'value' => $input[$field],
- 'rule' => __FUNCTION__,
- 'param' => $param,
- ];
-
- if (!is_array($input[$field])) {
- return $err;
+ if (!empty($errors)) {
+ foreach ($errors as $error) {
+ $flash->addMessage('error', $error);
+ }
}
-
- // default value
- if (empty($param)) $param = 1;
-
- if (count($input[$field]) < $param) return $err;
-
- return true;
}
/**
@@ -179,109 +230,58 @@ class ValidationHelper extends GUMP
return $resp;
}
- /**
- * Perform data validation against the provided ruleset
- *
- * Arrays as FIELDS are added here as a custom feature
- *
- * @access public
- * @param mixed $input
- * @param array $ruleset
- * @return mixed
- * @throws \Exception
+ /** Validates if $field content is equal to $param
+ * @param $field
+ * @param $input
+ * @param $param
+ * @return bool
*/
- public function validate(array $input, array $ruleset)
+ protected function validate_equals($field, $input, $param)
{
- $this->errors = [];
+ $err = [
+ 'field' => $field,
+ 'value' => $input[$field],
+ 'rule' => __FUNCTION__,
+ 'param' => $param,
+ ];
- foreach ($ruleset as $field => $rules) {
- #if(!array_key_exists($field, $input))
- #{
- # continue;
- #}
-
- $rules = explode('|', $rules);
-
- if (in_array("required", $rules) || (isset($input[$field]) && (is_array($input[$field]) || trim($input[$field]) != ''))) {
-
- foreach ($rules as $rule) {
- $method = NULL;
- $param = NULL;
-
- if (strstr($rule, ',') !== false) // has params
- {
- $rule = explode(',', $rule);
- $method = 'validate_' . $rule[0];
- $param = $rule[1];
- $rule = $rule[0];
- } else {
- $method = 'validate_' . $rule;
- }
-
- // array required
- if ($rule === "required" && !isset($input[$field])) {
- $result = $this->$method($field, $input, $param);
- $this->errors[] = $result;
-
- return;
- }
-
- if (is_callable([$this, $method])) {
- $result = $this->$method($field, $input, $param);
-
- if (is_array($result)) // Validation Failed
- {
- $this->errors[] = $result;
-
- return $this->errors;
- }
- } else {
- if (isset(self::$validation_methods[$rule])) {
- if (isset($input[$field])) {
- $result = call_user_func(self::$validation_methods[$rule], $field, $input, $param);
-
- $result = $this->$method($field, $input, $param);
-
- if (is_array($result)) // Validation Failed
- {
- $this->errors[] = $result;
-
- return $this->errors;
- }
- }
- } else {
- throw new \Exception("Validator method '$method' does not exist.");
- }
- }
- }
- }
+ if (!isset($input[$field]) || empty($input[$field]) || empty($param) || !isset($param)) {
+ return $err;
}
- return (count($this->errors) > 0) ? $this->errors : true;
- }
+ if ($input[$field] != $param || $input[$field] !== $param) {
+ return $err;
+ }
- public function filter_upper($value, $param = NULL)
- {
- return strtoupper($value);
- }
-
- public function filter_lower($value, $param = NULL)
- {
- return strtolower($value);
+ return true;
}
/**
- * Converts all error array into a single string
- * @return void
+ * Validates if array has min size, defaults to size = 1
+ * @param $field
+ * @param $input
+ * @param null $param
+ * @return array|bool
*/
- public function addErrorsToFlashMessage($flash)
+ protected function validate_set_min_len($field, $input, $param = NULL)
{
- $errors = $this->get_errors_array(true);
- if (!empty($errors)) {
- foreach ($errors as $error) {
- $flash->addMessage('error', $error);
- }
+ $err = [
+ 'field' => $field,
+ 'value' => $input[$field],
+ 'rule' => __FUNCTION__,
+ 'param' => $param,
+ ];
+
+ if (!is_array($input[$field])) {
+ return $err;
}
+
+ // default value
+ if (empty($param)) $param = 1;
+
+ if (count($input[$field]) < $param) return $err;
+
+ return true;
}
-}
\ No newline at end of file
+}
diff --git a/src/View/delete.twig b/src/View/delete.twig
index 3ddaf71..95b1b83 100644
--- a/src/View/delete.twig
+++ b/src/View/delete.twig
@@ -8,7 +8,9 @@