[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [ocs-webserver] /: login repair
From: Ronald von Schlegell <null () kde ! org>
Date: 2018-09-20 14:01:17
Message-ID: E1g2zW9-0004xC-J4 () code ! kde ! org
[Download RAW message or body]
Git commit a097cdb2845538a0d08ec53d20bfea16ff83dc44 by Ronald von Schlegell.
Committed on 20/09/2018 at 14:01.
Pushed by ronaldv into branch 'master'.
login repair
M +17 -14 application/modules/default/controllers/AuthorizationController.php
M +5 -0 application/modules/default/controllers/RectificationController.php
M +11 -4 application/modules/default/models/ReviewProfileData.php
M +12 -4 application/modules/default/views/scripts/rectification/change.phtml
A +3 -0 sql_code/20180920_add_member_username_old.sql
https://commits.kde.org/ocs-webserver/a097cdb2845538a0d08ec53d20bfea16ff83dc44
diff --git a/application/modules/default/controllers/AuthorizationController.php \
b/application/modules/default/controllers/AuthorizationController.php index \
f4ce77d3..f6da3e8a 100644
--- a/application/modules/default/controllers/AuthorizationController.php
+++ b/application/modules/default/controllers/AuthorizationController.php
@@ -414,20 +414,23 @@ class AuthorizationController extends \
Local_Controller_Action_DomainSwitch
setcookie(Default_Model_SingleSignOnToken::ACTION_LOGIN, $token_id, time() + \
120, '/',
Local_Tools_ParseDomain::get_domain($this->getRequest()->getHttpHost()), \
null, true);
- //$modelReviewProfile = new Default_Model_ReviewProfileData();
- //if (false === \
$modelReviewProfile->hasValidProfile($auth->getStorage()->read())) {
- // if ($this->_request->isXmlHttpRequest()) {
- // $redirect = $this->getParam('redirect') ? '/redirect/' . \
$this->getParam('redirect') : '';
- // $this->_helper->json(array('status' => 'ok',
- // 'redirect' => '/r/change/e/' . \
$modelReviewProfile->getErrorCode() . $redirect
- // ));
- // } else {
- // $this->getRequest()->setParam('member_id', $userId);
- // $this->redirect("/r/change/e/" . \
$modelReviewProfile->getErrorCode(), $this->getAllParams());
- // }
- //
- // return;
- //}
+
+ //user has to correct his data?
+
+ $modelReviewProfile = new Default_Model_ReviewProfileData();
+ if (false === \
$modelReviewProfile->hasValidProfile($auth->getStorage()->read())) { + if \
($this->_request->isXmlHttpRequest()) { + $redirect = \
$this->getParam('redirect') ? '/redirect/' . $this->getParam('redirect') : ''; + \
$this->_helper->json(array('status' => 'ok', + \
'redirect' => '/r/change/e/' . $modelReviewProfile->getErrorCode() . $redirect + \
)); + } else {
+ $this->getRequest()->setParam('member_id', $userId);
+ $this->redirect("/r/change/e/" . \
$modelReviewProfile->getErrorCode(), $this->getAllParams()); + }
+
+ return;
+ }
// handle redirect
$this->handleRedirect($userId);
diff --git a/application/modules/default/controllers/RectificationController.php \
b/application/modules/default/controllers/RectificationController.php index \
f49a6c21..7efcebee 100644
--- a/application/modules/default/controllers/RectificationController.php
+++ b/application/modules/default/controllers/RectificationController.php
@@ -66,11 +66,16 @@ class RectificationController extends \
Local_Controller_Action_DomainSwitch
if (isset($values['username']) AND ($member->username != \
$values['username'])) { $oldUsername = $member->username;
$member->username = $values['username'];
+ $member->username_old = $oldUsername;
$member->save();
$this->_authMember->username = $values['username'];
}
if (isset($values['mail'])) {
$this->_authMember->mail = $values['mail'];
+
+ $member->mail_old = $member->mail;
+ $member->save();
+
$modelEmail = new Default_Model_MemberEmail();
$dataMail = \
$modelEmail->saveEmailAsPrimary($this->_authMember->member_id, \
$values['mail']);
$modelEmail->sendConfirmationMail((array)$this->_authMember, \
$dataMail->email_verification_value);
diff --git a/application/modules/default/models/ReviewProfileData.php \
b/application/modules/default/models/ReviewProfileData.php index be26df33..6917bce7 \
100644
--- a/application/modules/default/models/ReviewProfileData.php
+++ b/application/modules/default/models/ReviewProfileData.php
@@ -27,6 +27,10 @@ class Default_Model_ReviewProfileData
const INVALID_USERNAME = 1;
const INVALID_EMAIL = 2;
+
+ const INVALID_USERNAME_NOT_ALLOWED = 11;
+ const INVALID_USERNAME_NOT_UNIQUE = 12;
+
protected $message;
protected $errorCode;
@@ -49,10 +53,12 @@ class Default_Model_ReviewProfileData
if (false == $result) {
return false;
}
+ /*
$result = $this->hasValidEmail($member_data);
if (false == $result) {
return false;
}
+ */
return true;
}
@@ -68,7 +74,7 @@ class Default_Model_ReviewProfileData
foreach ($this->usernameValidationChain as $validator) {
$result = $this->$validator($member_data);
if (false == $result) {
- $this->errorCode |= self::INVALID_USERNAME;
+ //$this->errorCode |= self::INVALID_USERNAME;
return false;
}
}
@@ -82,7 +88,7 @@ class Default_Model_ReviewProfileData
foreach ($this->emailValidationChain as $validator) {
$result = $this->$validator($member_data);
if (false == $result) {
- $this->errorCode |= self::INVALID_EMAIL;
+ //$this->errorCode |= self::INVALID_EMAIL;
return false;
}
}
@@ -159,10 +165,11 @@ class Default_Model_ReviewProfileData
*/
private function isUsernameValid($member_data)
{
- $usernameValidChars = new \
Zend_Validate_Regex('/^(?=.{4,40}$)(?![-])(?!.*[-]{2})[a-z0-9-]+(?<![-])$/'); + \
$usernameValidChars = new \
Zend_Validate_Regex('/^(?=.{3,40}$)(?![-])(?!.*[-]{2})[a-zA-Z0-9-]+(?<![-])$/');
if (false == $usernameValidChars->isValid($member_data->username)) {
$this->message['username'][] = $usernameValidChars->getMessages();
+ $this->errorCode = $this::INVALID_USERNAME_NOT_ALLOWED;
return false;
}
@@ -190,7 +197,7 @@ class Default_Model_ReviewProfileData
if (is_array($result) AND count($result) > 0) {
$this->message['username'][] = array('username is not unique');
-
+ $this->errorCode = $this::INVALID_USERNAME_NOT_UNIQUE;
return false;
}
diff --git a/application/modules/default/views/scripts/rectification/change.phtml \
b/application/modules/default/views/scripts/rectification/change.phtml index \
f8ce808d..2e39792a 100644
--- a/application/modules/default/views/scripts/rectification/change.phtml
+++ b/application/modules/default/views/scripts/rectification/change.phtml
@@ -36,7 +36,14 @@ $this->inlineScript()->appendFile('/theme/flatui/js/lib/bootstrap-validator.min.
<h3><?= $this->translate('Please change your profile.') \
?></h3>
<div id="help-block" class="help-block">
- <?= $this->translate('For technical reasons, we have to \
ask you to change your profile information. ') ?> + <?php
+ $errCode = $this->errorCode;
+ if($errCode == \
Default_Model_ReviewProfileData::INVALID_USERNAME_NOT_ALLOWED) { + \
print_r("Your username contains invalid characters. Please correct it."); + \
} else if($errCode == Default_Model_ReviewProfileData::INVALID_USERNAME_NOT_UNIQUE) { \
+ print_r("Your username is also being used by \
another user. Please change it."); + }
+ ?>
</div>
<div id="error" class="center text-error help-block">
<?php if ($this->error && isset($this->errorText)): ?>
@@ -52,13 +59,14 @@ $this->inlineScript()->appendFile('/theme/flatui/js/lib/bootstrap-validator.min.
}
?>
- <?php if ($this->errorCode & \
Default_Model_ReviewProfileData::INVALID_USERNAME) : ?> + \
<?php if (($this->errorCode == \
Default_Model_ReviewProfileData::INVALID_USERNAME_NOT_ALLOWED || $this->errorCode == \
Default_Model_ReviewProfileData::INVALID_USERNAME_NOT_UNIQUE) ) : ?> <div \
class="form-group has-feedback">
- <label for="username" class="control-label">Please \
enter a new username, which may consist of lowercase english letters, numbers, \
hyphen, underscore and/or period.</label> + <label \
for="username" class="control-label">The username has to be unique and may only \
contain lower case alphanumeric characters or single hyphens, and cannot begin or end \
with a hyphen</label> <input name="username" id="username" value="" type="text" \
placeholder="Username" data-minlength="4" class="form-control" required \
data-minlength-error="Minimum of 4 characters" data-maxlength="40" \
data-maxlength-error="Maximum of 40 characters"><div class="help-block \
with-errors"></div> </div>
<?php endif ?>
- <?php if ($this->errorCode & \
Default_Model_ReviewProfileData::INVALID_EMAIL) : ?> +
+ <?php if ($this->errorCode == \
Default_Model_ReviewProfileData::INVALID_EMAIL) : ?> <div class="form-group \
has-feedback">
<label for="email" class="control-label">Please \
enter a valid email address.</label> <input type="email" class="form-control" \
placeholder="Email" value="" id="mail" name="mail" required><div class="help-block \
with-errors"></div>
diff --git a/sql_code/20180920_add_member_username_old.sql \
b/sql_code/20180920_add_member_username_old.sql new file mode 100644
index 00000000..0bd39666
--- /dev/null
+++ b/sql_code/20180920_add_member_username_old.sql
@@ -0,0 +1,3 @@
+ALTER TABLE `member`
+ ADD COLUMN `username_old` VARCHAR(255) NULL DEFAULT NULL AFTER `password_type_old`,
+ ADD COLUMN `mail_old` VARCHAR(255) NULL DEFAULT NULL AFTER `username_old`;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic