registration mit mail und aktivierung fertig

This commit is contained in:
Martin Müller 2014-04-09 19:30:26 +02:00
parent 9af75229fe
commit ddaa34bb7a
9 changed files with 57 additions and 8 deletions

View File

@ -34,7 +34,7 @@
Router::connect('/registration', array('controller' => 'registration', 'action' => 'main')); Router::connect('/registration', array('controller' => 'registration', 'action' => 'main'));
Router::connect('/registration/user', array('controller' => 'registration', 'action' => 'worker')); Router::connect('/registration/user', array('controller' => 'registration', 'action' => 'worker'));
Router::connect('/registration/company', array('controller' => 'registration', 'action' => 'company')); Router::connect('/registration/company', array('controller' => 'registration', 'action' => 'company'));
Router::connect('/registration/active/:code', array('controller' => 'registration', 'action' => 'active'),array("code" => "(?i:code)")); Router::connect('/registration/active/:code', array('controller' => 'registration', 'action' => 'active'),array("code" => ".+"));
Router::connect('/profil', array('controller' => 'user', 'action' => 'profil')); Router::connect('/profil', array('controller' => 'user', 'action' => 'profil'));
Router::connect('/profil/page/:page', array('controller' => 'user', 'action' => 'profil'),array("page" => "[0-9]+")); Router::connect('/profil/page/:page', array('controller' => 'user', 'action' => 'profil'),array("page" => "[0-9]+"));

View File

@ -11,7 +11,7 @@ class RegistrationController extends AppController {
* @var array * @var array
*/ */
public $componens = array('Email','MiconwareSession'); public $componens = array('Email','MiconwareSession');
public $uses = array('Mannerofaddress','DreamjobListGraducation','DreamjobListBranch','DreamjobWorker','DreamjobCompany'); public $uses = array('Mannerofaddress','DreamjobListGraducation','DreamjobListBranch','DreamjobWorker','DreamjobCompany','User');
private function registrationMail($data,$key){ private function registrationMail($data,$key){
$Email = new CakeEmail('dreamjobMain'); $Email = new CakeEmail('dreamjobMain');
@ -145,9 +145,17 @@ class RegistrationController extends AppController {
} }
} }
public function active(){ public function active(){
$this->MiconwareSession->init($this);
$this->MiconwareSession->initWeb($this);
if(!$this->MiconwareSession->isLoggedin() and !empty($this->request->params['code']) and !empty($this->request->query['mail']) ){
$result = $this->User->activeLinkUser($this->request->query['mail'],$this->request->params['code']);
$this->set("result",$result);
$this->render('/Registration/active');
}else{
$this->set('error', 'dreamjob.error.loggedin'); $this->set('error', 'dreamjob.error.loggedin');
$this->render('/Home/error'); $this->render('/Home/error');
} }
}
} }
?> ?>

View File

@ -74,7 +74,7 @@ class DreamjobCompany extends AppModel {
} }
if ($result) { if ($result) {
$dataSource->rollback(); $dataSource->commit();
return true; return true;
} else { } else {
$dataSource->rollback(); $dataSource->rollback();

View File

@ -88,7 +88,7 @@ class DreamjobWorker extends AppModel {
} }
if ($result) { if ($result) {
$dataSource->rollback(); $dataSource->commit();
return true; return true;
} else { } else {
$dataSource->rollback(); $dataSource->rollback();

View File

@ -33,6 +33,29 @@ class User extends AppModel {
* *
* @var array * @var array
*/ */
public function activeLinkUser($mail,$key){
$dataSource = $this->getDataSource();
$dataSource->begin();
$data = $this->find('first',array('conditions' => array(
'mail' => $mail,
'code'=> 'a:'.$key
)));
$result = false;
if(!empty($data) and count($data)>0){
$this->id = $data['User']['id'];
$result = $this->saveField('code','');
if($result)
$result = $this->saveField('is_active',true);
}
if($result) {
$dataSource->commit();
return true;
} else {
$dataSource->rollback();
}
return false;
}
public $validate = array( public $validate = array(
'id' => array( 'id' => array(
'multiple' => array( 'multiple' => array(

View File

@ -1,3 +1,4 @@
<?php <?php
echo $this->Html->link(__('dreamjob.regisration.active.link'),array('controller'=>'registration','action'=>'active','code'=>$key)); echo $this->Html->link(__('dreamjob.regisration.active.link'),array('controller' => 'registration', 'action' => 'active','code'=>$key,
'?'=>array('mail'=>$data['User']['mail'])));
?> ?>

View File

@ -1,3 +1,4 @@
<?php <?php
echo $this->Html->url(array('controller'=>'registration','action'=>'active','code'=>$key)); echo $this->Html->url(array('controller'=>'registration','action'=>'active','code'=>$key
'?'=>array('mail'=>$data['User']['mail'])));
?> ?>

View File

@ -0,0 +1,12 @@
<?php
?>
<div class="box">
<h1><?=__('dreamjob.active');?></h1>
<?php
if($result){
echo __('dreamjob.active.done');
}else{
echo __('dreamjob.active.error');
}
?>
</div

View File

@ -4,8 +4,12 @@ $this->start('barleft');
Test, nicht fuer User geeignet. Test, nicht fuer User geeignet.
<?php <?php
$this->end(); $this->end();
$key = "af4oi";
?> ?>
<div class="box"> <div class="box">
<?php
echo $this->Html->link(__('dreamjob.regisration.active.link'),array('controller'=>'registration','action'=>'active','code'=>$key,'?'=>array('mail'=>'mueller@miconware.de')));
?>
<?=var_dump($data);?> <?=var_dump($data);?>
</div> </div>