Skip to content

Instantly share code, notes, and snippets.

Created October 2, 2014 19:23
Show Gist options
  • Save anonymous/415e5464b1c49333efb4 to your computer and use it in GitHub Desktop.
Save anonymous/415e5464b1c49333efb4 to your computer and use it in GitHub Desktop.
class AppController extends Controller {
public $components = array(
'Session',
'Cookie',
'Auth',
'Security'
);
public function beforeFilter() {
$this->Auth->allow();
}
<?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>
<?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.'
)
);
}
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