Created
October 2, 2014 19:23
-
-
Save anonymous/415e5464b1c49333efb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppController extends Controller { | |
public $components = array( | |
'Session', | |
'Cookie', | |
'Auth', | |
'Security' | |
); | |
public function beforeFilter() { | |
$this->Auth->allow(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo $this->Session->flash(); ?> | |
<div class="col-md-4 column"> | |
<fieldset> | |
<legend>Se connecter</legend> | |
<?php echo $this->Form->create('Member'); ?> | |
<div class="forum-group"> | |
<?php echo $this->Form->input('pseudo', array('label' => 'Login :', 'class' => 'form-control')); ?> | |
</div> | |
<div class="forum-group"> | |
<?php echo $this->Form->input('password', array('label' => 'Mot de passe :', 'class' => 'form-control')); ?> | |
</div> | |
<br /> | |
<div class="group-form"> | |
<?php echo $this->Form->submit('Me connecter', array('class' => 'btn btn-success')); ?> | |
</div> | |
<?php echo $this->Form->end(); ?> | |
</fieldset> | |
</div> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Member extends AppModel { | |
public $validate = array( | |
'pseudo' => array( | |
array( | |
'rule' => 'alphanumeric', | |
'required' => true, | |
'allowEmpty' => false, | |
'message' => 'Pseudo invalide' | |
), | |
array( | |
'rule' => 'isUnique', | |
'message' => 'Ce pseudo est déjà pris.' | |
) | |
), | |
'mail' => array( | |
array( | |
'rule' => 'email', | |
'required' => true, | |
'allowEmpty' => false, | |
'message' => 'Email invalide' | |
), | |
array( | |
'rule' => 'isUnique', | |
'message' => 'Cet email est déjà pris.' | |
) | |
), | |
'password' => array( | |
'rule' => 'notEmpty', | |
'allowEmpty' => false, | |
'message' => 'Entrez un mot de passe.' | |
) | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function login() { | |
if($this->request->is('post')) { | |
if($this->Auth->login()) { | |
$this->Session->setFlash('Connecté', 'success'); | |
}else{ | |
$this->Session->setFlash('Pas connecté', 'error'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment