check if unique values already exists for user and Character registration and send notification mail to moderators
This commit is contained in:
parent
f394946fa2
commit
babfe5b017
11 changed files with 290 additions and 34 deletions
|
|
@ -164,9 +164,16 @@
|
|||
// Get params and validate them
|
||||
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||
$username = $this->request->getPostParam('username');
|
||||
if($this->Users->usernameExists($username)) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'username', 'exist', true);
|
||||
}
|
||||
$prename = $this->request->getPostParam('prename');
|
||||
$surname = $this->request->getPostParam('surname');
|
||||
$email = $this->request->getPostParam('email');
|
||||
if($this->Users->emailExists($email)) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'email', 'exist', true);
|
||||
}
|
||||
|
||||
|
||||
// Register
|
||||
if($validation === true)
|
||||
|
|
@ -178,7 +185,10 @@
|
|||
$email,
|
||||
$this->request->getPostParam('password')
|
||||
);
|
||||
|
||||
|
||||
// Send mail
|
||||
$this->sendRegistrationMail($username, $email);
|
||||
|
||||
// Login
|
||||
$this->Auth->setUserId($userId);
|
||||
$user = $this->Users->getUserById($userId);
|
||||
|
|
@ -323,6 +333,31 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Send mail for new user registration.
|
||||
*
|
||||
* @param string $username Name of newly registered user
|
||||
* @param string $email E‑mail address of newly registered user
|
||||
*/
|
||||
private function sendRegistrationMail($username, $email)
|
||||
{
|
||||
$sender = \nre\configs\AppConfig::$app['mailsender'];
|
||||
if(empty($sender)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Send notification mail to system moderators
|
||||
$subject = sprintf('new user registration: %s', $username);
|
||||
$message = sprintf('User “%s” <%s> has registered themself to %s', $username, $email, \nre\configs\AppConfig::$app['name']);
|
||||
$moderators = $this->Users->getUsersWithRole('moderator');
|
||||
foreach($moderators as &$moderator)
|
||||
{
|
||||
\hhu\z\Utils::sendMail($sender, $moderator['email'], $subject, $message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue