用户字段,activation_key字符串,状态int = 0默认值,
激活的配置文件将具有status = 1 但即使用户尚未激活,它也会一直登录,
如果已经激活,则用户可以登录,但如果尚未激活则会发出消息“请先激活”
假设我的激活方法已经完成,
<?php
public function login()
{
if ($this->request->is('post')) {
if (Validation::email($this->request->data['username'])) {
$this->Auth->config('authenticate', [
'Form' => [
'fields' => ['username' => 'email']
]
]);
$this->Auth->constructAuthenticate();
$this->request->data['email'] = $this->request->data['username'];
unset($this->request->data['username']);
}
$user = $this->Auth->identify();
if ($user) {
$this->Auth->setUser($user);
return $this->redirect($this->Auth->redirectUrl());
}
$this->Flash->error(__('Invalid username or password, try again'));
}
}
?>
答案 0 :(得分:2)
您可以在身份验证后和<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="#" class="step-form d-flex">
<div class="slide">
<h3>Enter your code1</h3>
<input type="text" class="input-field" placeholder="ZIP CODE">
<p><a href="#" class="btn-start">Start now!</a></p>
</div>
<div class="slide">
<h3>Enter your code2</h3>
<input type="text" class="input-field" placeholder="ZIP CODE">
<p><a href="#" class="btn-start">Start now!</a></p>
</div>
</form>
之前检查状态。
示例强>
setUser()