close #14 New registration mail

This commit is contained in:
Exodus4D
2015-09-12 18:55:35 +02:00
parent 71411248c7
commit a1dbbe39d5
5 changed files with 63 additions and 19 deletions

View File

@@ -277,9 +277,12 @@ class User extends Controller\Controller{
$newUserData = null;
// check user if if he is new
// check for new user
$loginAfterSave = false;
// send registration mail
$sendRegistrationMail = false;
// valid registration key Model is required for new registration
// if "invite" feature is enabled
$registrationKeyModel = false;
@@ -314,6 +317,7 @@ class User extends Controller\Controller{
// new user registration
$user = $mapType = Model\BasicModel::getNew('UserModel');
$loginAfterSave = true;
$sendRegistrationMail = true;
// set username
if(
@@ -344,6 +348,9 @@ class User extends Controller\Controller{
$settingsData['password'] == $settingsData['password_confirm']
){
$user->password = $settingsData['password'];
// pw changed -> send mail
$sendRegistrationMail = true;
}
}else{
// captcha was send but not valid -> return error
@@ -444,6 +451,12 @@ class User extends Controller\Controller{
// get fresh updated user object
$user = $this->_getUser(0);
$newUserData = $user->getData();
// send registration mail with account information
if($sendRegistrationMail){
$this->sendRegistration($user, $settingsData['password']);
}
}
}catch(Exception\ValidationException $e){
$validationError = (object) [];
@@ -466,13 +479,30 @@ class User extends Controller\Controller{
echo json_encode($return);
}
/**
* send registration mail to user
* @param $user
* @param $password
* @return mixed
*/
protected function sendRegistration($user, $password){
$msg = 'Username: ' . $user->name . '<br>';
$msg .= 'Password: ' . $password . '<br>';
$mailController = new MailController();
$status = $mailController->sendRegistration($user->email, $msg);
return $status;
}
/**
* send mail with registration key
* -> check INVITE in pathfinder.ini
* @param $f3
* @throws Exception
*/
public function sendRegistration($f3){
public function sendInvite($f3){
$data = $f3->get('POST.settingsData');
$return = (object) [];
@@ -529,7 +559,7 @@ class User extends Controller\Controller{
}else{
$validationError = (object) [];
$validationError->type = 'warning';
$validationError->message = 'The number of keys is limited per an Email. You can not get more keys';
$validationError->message = 'The number of keys is limited by Email. You can not get more keys';
$return->error[] = $validationError;
}
@@ -542,7 +572,7 @@ class User extends Controller\Controller{
$msg = 'Your personal Registration Key: ' . $registrationKeyModel->registrationKey;
$mailController = new MailController();
$status = $mailController->sendRegistrationKey($email, $msg);
$status = $mailController->sendInviteKey($email, $msg);
if( $status ){
$registrationKeyModel->email = $email;

View File

@@ -23,22 +23,36 @@ class MailController extends \SMTP{
// error handling
$this->set('Errors-to', '' . Controller::getEnvironmentData('SMTP_ERROR') . '>');
$this->set('MIME-Version', '1.0');
$this->set('Content-Type', 'text/html; charset=ISO-8859-1');
}
/**
* send registration key
* send registration mail
* @param $to
* @param $msg
* @return bool
*/
public function sendRegistrationKey($to, $msg){
public function sendRegistration($to, $msg){
$this->set('To', '<' . $to . '>');
$this->set('From', 'Pathfinder <' . Controller::getEnvironmentData('SMTP_FROM') . '>');
$this->set('Subject', 'Account information');
$status = $this->send($msg);
return $status;
}
/**
* send invite key mail
* @param $to
* @param $msg
* @return bool
*/
public function sendInviteKey($to, $msg){
$this->set('To', '<' . $to . '>');
$this->set('From', 'Pathfinder <' . Controller::getEnvironmentData('SMTP_FROM') . '>');
$this->set('Subject', 'Registration Key');
$this->set('Error-To', '<' . Controller::getEnvironmentData('SMTP_ERROR') . '>');
$this->set('MIME-Version', '1.0');
$this->set('Content-Type', 'text/html; charset=ISO-8859-1');
$status = $this->send($msg);
return $status;

View File

@@ -10,15 +10,15 @@ namespace Data\Mapper;
class CcpSystemsMapper extends \RecursiveArrayIterator {
static $map = array(
static $map = [
'system_id' => 'systemId',
'system_name' => 'name',
'system_security' => 'trueSec',
'connstallation_id' => array('constellation' => 'id'),
'constallation_name' => array('constellation' => 'name'),
'region_id' => array('region' => 'id'),
'region_name' => array('region' => 'name')
);
'connstallation_id' => ['constellation' => 'id'],
'constallation_name' => ['constellation' => 'name'],
'region_id' => ['region' => 'id'],
'region_name' => ['region' => 'name']
];
function __construct($data){
@@ -106,7 +106,7 @@ class CcpSystemsMapper extends \RecursiveArrayIterator {
];
};
iterator_apply($this, 'self::recursiveIterator', array($this));
iterator_apply($this, 'self::recursiveIterator', [$this]);
return iterator_to_array($this, false);
@@ -143,7 +143,7 @@ class CcpSystemsMapper extends \RecursiveArrayIterator {
$iterator->offsetSet( $parentKey, $currentValue );
}else{
$iterator->offsetSet( $parentKey, array($entryKey => $iterator->current() ) );
$iterator->offsetSet( $parentKey, [$entryKey => $iterator->current() ] );
}
$removeOldEntry = true;

View File

@@ -11,7 +11,7 @@ define(['jquery'], function($) {
img: 'public/img/', // path for images
// user API
getCaptcha: 'api/user/getCaptcha', // ajax URL - get captcha image
sendRegistrationKey: 'api/user/sendRegistration', // ajax URL - send registration key
sendInviteKey: 'api/user/sendInvite', // ajax URL - send registration key
logIn: 'api/user/logIn', // ajax URL - login
logOut: 'api/user/logOut', // ajax URL - logout
deleteLog: 'api/user/deleteLog', // ajax URL - delete character log

View File

@@ -192,7 +192,7 @@ define([
$.ajax({
type: 'POST',
url: Init.path.sendRegistrationKey,
url: Init.path.sendInviteKey,
data: requestData,
dataType: 'json'
}).done(function(responseData){