Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorPeter Zhang <peter@innocraft.com>2022-06-07 02:47:10 +0300
committerGitHub <noreply@github.com>2022-06-07 02:47:10 +0300
commitd036954668dcd4cf8cb4a5235cbed7519503d0f6 (patch)
tree7abe98a4dba386675aa60daf66dcc3331c1230fd /core
parent3afdfcaa029d93ea3a5db53b0966e8d41f0e7749 (diff)
invite user replace add user (#18868)
* draft vue version draft vue version * built vue files * update some functions update some functions * Update API.php update wording * move some validation move some validation * built vue files * update some structure update some structure * update validators update validators * update some changes update some changes * update invite update invite * add status add status * built vue files * add invite page add invite page * add invite page add invite page * add some api back add some api back * Update UserRepository.php update tests * update all xml in the tests update all xml in the tests * update tests update tests * update tests update tests * Update LoginLdap update tests * Update UsersManagerTest.php update tests * update tests update tests * Update APITest.php update tests * Update UserInviteEmail.php fix cs * update cs update cs * Update SessionAuthTest.php update tests * update tests error update tests error * Update UserRepository.php remove unused * update tests update tests * update user tests update user tests * update tests update tests * Update API.php update tests * built vue files * Update OmniFixture-dump.sql update tests * update validator update validator * built vue files * update tests and screenshots update tests and screenshots * update test xml update test xml * update user total size update user total size * update tests update tests * built vue files * update tests and test user email update tests and test user email * update tests update tests * built vue files * update tests update tests * update ranking in screenshots update ranking in screenshots * update test update test * update tests change the table list order * Update UsersManager_spec.js update tests * update tests update tests * built vue files * update tests update tests * update tests update tests * update tests update tests * adding login tests adding login tests * update tests update tests * Update UsersManager_resend_popup.png add screenshots * Update PendingUsers.php update error of model * update tests update tests * Update UserInviteTest.php update tests error * update set up for pending user should be pending user * update screenshots update screenshots * update wrong password check update wrong password check * Update Invite_wrong_password.png update password * update to 4.10 update to 4.10 * Update ReportParameters.vue remove un used element * update vue file update vue file * hide password on invite user hide password on invite user * built vue files * built vue files * Update UserEditForm.vue update password condition * built vue files * update condition on pending user update condition on pending user * built vue files * update screenshots update screenshots * update bugs update bugs * built vue files * add expired status add expired status * fix php cs fix php cs * update vue error update vue error * built vue files * add decline interface add decline interface * update all the user status update all the user status * built vue files * update tests xml for invite status update tests * fix phpcs fix phpcs * update migration number update migration number * update tests email update tests email * update screenshot tests update screenshot tests * update tests update tests * update screenshots * update screenshots update screenshots * Update Invite_wrong_password.png update screenshots * update status update status * update tests update tests * update tests update tests * Update TwoFactorAuthUsersManager_spec.js update tests * Update TwoFactorAuthUsersManager_spec.js update tests * update tests update tests * update lang update lang * update some errors update some errors * update screenshots update screenshots * update ui tests and resend invitation update ui tests and resend invitation * fix resend fix resend * built vue files * update screenshots update screenshots Co-authored-by: peterhashair <peterhashair@users.noreply.github.com>
Diffstat (limited to 'core')
-rw-r--r--core/Db/Schema/Mysql.php5
-rw-r--r--core/Piwik.php3
-rw-r--r--core/Updates/4.10.0-b1.php2
-rw-r--r--core/Updates/4.11.0-b1.php52
-rw-r--r--core/Validators/Login.php59
5 files changed, 118 insertions, 3 deletions
diff --git a/core/Db/Schema/Mysql.php b/core/Db/Schema/Mysql.php
index fcf943bbdd..00fb8c31e9 100644
--- a/core/Db/Schema/Mysql.php
+++ b/core/Db/Schema/Mysql.php
@@ -53,6 +53,7 @@ class Mysql implements SchemaInterface
date_registered TIMESTAMP NULL,
ts_password_modified TIMESTAMP NULL,
idchange_last_viewed TIMESTAMP NULL,
+ invite_status enum('accept','pending','decline','expired') DEFAULT 'accept',
PRIMARY KEY(login)
) ENGINE=$engine DEFAULT CHARSET=$charset
",
@@ -589,8 +590,8 @@ class Mysql implements SchemaInterface
$db = $this->getDb();
$db->query("INSERT IGNORE INTO " . Common::prefixTable("user") . "
(`login`, `password`, `email`, `twofactor_secret`, `superuser_access`, `date_registered`, `ts_password_modified`,
- `idchange_last_viewed`)
- VALUES ( 'anonymous', '', 'anonymous@example.org', '', 0, '$now', '$now' , NULL);");
+ `idchange_last_viewed`, `invite_status`)
+ VALUES ( 'anonymous', '', 'anonymous@example.org', '', 0, '$now', '$now' , NULL, 'accept');");
$model = new Model();
$model->addTokenAuth('anonymous', 'anonymous', 'anonymous default token', $now);
diff --git a/core/Piwik.php b/core/Piwik.php
index 0c9c1ff66a..b970efa1db 100644
--- a/core/Piwik.php
+++ b/core/Piwik.php
@@ -708,6 +708,7 @@ class Piwik
*/
/**
+ * TODO: consider deprecated it, move to validator
* Returns `true` if supplied the email address is a valid.
*
* @param string $emailAddress
@@ -720,6 +721,7 @@ class Piwik
}
/**
+ * TODO: consider deprecated it, move to validator
* Returns `true` if the login is valid.
*
* _Warning: does not check if the login already exists! You must use UsersManager_API->userExists as well._
@@ -917,4 +919,5 @@ class Piwik
{
return Common::getRequestVar('date', $default, 'string');
}
+
}
diff --git a/core/Updates/4.10.0-b1.php b/core/Updates/4.10.0-b1.php
index df8d408041..c4e81584bf 100644
--- a/core/Updates/4.10.0-b1.php
+++ b/core/Updates/4.10.0-b1.php
@@ -50,7 +50,7 @@ class Updates_4_10_0_b1 extends PiwikUpdates
}
return [
- $this->migration->db->sql("DELETE FROM " . $table . " WHERE reports = 'Array' OR parameters = 'Array'")
+ $this->migration->db->sql("DELETE FROM " . $table . " WHERE reports = 'Array' OR parameters = 'Array'"),
];
}
diff --git a/core/Updates/4.11.0-b1.php b/core/Updates/4.11.0-b1.php
new file mode 100644
index 0000000000..d9bf37bc99
--- /dev/null
+++ b/core/Updates/4.11.0-b1.php
@@ -0,0 +1,52 @@
+<?php
+
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+
+namespace Piwik\Updates;
+
+use Piwik\Updater;
+use Piwik\Updater\Migration;
+use Piwik\Updater\Migration\Factory as MigrationFactory;
+use Piwik\Updates as PiwikUpdates;
+
+/**
+ * Update for version 4.11.0-b1
+ */
+class Updates_4_11_0_b1 extends PiwikUpdates
+{
+ /**
+ * @var MigrationFactory
+ */
+ private $migration;
+
+ public function __construct(MigrationFactory $factory)
+ {
+ $this->migration = $factory;
+ }
+
+ /**
+ * @param Updater $updater
+ *
+ * @return Migration[]
+ */
+ public function getMigrations(Updater $updater)
+ {
+
+ return [
+ $this->migration->db->addColumns('user', [
+ 'invite_status' => "ENUM('accept','pending','decline','expired') DEFAULT 'accept'"
+ ])
+ ];
+ }
+
+ public function doUpdate(Updater $updater)
+ {
+ $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
+ }
+}
diff --git a/core/Validators/Login.php b/core/Validators/Login.php
new file mode 100644
index 0000000000..f377f79bec
--- /dev/null
+++ b/core/Validators/Login.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+
+namespace Piwik\Validators;
+
+use Piwik\Piwik;
+use Piwik\SettingsPiwik;
+use Piwik\Plugins\UsersManager\API as APIUsersManager;
+
+class Login extends BaseValidator
+{
+ protected $login;
+ const loginMinimumLength = 2;
+ const loginMaximumLength = 100;
+
+
+ public function validate($value)
+ {
+ if (!SettingsPiwik::isUserCredentialsSanityCheckEnabled()
+ && !empty($value)
+ ) {
+ return;
+ }
+
+ $l = strlen($value);
+ if (!($l >= self::loginMinimumLength
+ && $l <= self::loginMaximumLength
+ && (preg_match('/^[A-Za-zÄäÖöÜüß0-9_.@+-]*$/D', $value) > 0))
+ ) {
+ throw new Exception(Piwik::translate('UsersManager_ExceptionInvalidLoginFormat',
+ array(self::loginMinimumLength, self::loginMaximumLength)));
+ }
+
+ $this->login = $value;
+ return $this;
+ }
+
+ public function isUnique()
+ {
+ if (empty($this->login)) {
+ throw new Exception(Piwik::translate('UsersManager_ExceptionInvalidLoginFormat',
+ array(self::loginMinimumLength, self::loginMaximumLength)));
+ }
+
+ if (APIUsersManager::getInstance()->userExists($this->login)) {
+ throw new Exception(Piwik::translate('UsersManager_ExceptionLoginExists', $this->login));
+ }
+
+ if (APIUsersManager::getInstance()->userEmailExists($this->login)) {
+ throw new Exception(Piwik::translate('UsersManager_ExceptionLoginExistsAsEmail', $this->login));
+ }
+ }
+} \ No newline at end of file