$ this-> request->在opencart客户登录文件中获取['令牌']的目的是什么?

时间:2017-12-12 19:19:10

标签: php opencart

尝试了解Opencart客户登录系统。 ControllerAccountLogin文件中的catalog>controller>account>login.php类的条件为if (!empty($this->request->get['token']))(在// Login override for admin users之后,评论),这让我陷入困境。

ControllerAccountLogin (这不是完整的控制器,只是我需要了解的部分)

class ControllerAccountLogin extends Controller {
    private $error = array();

    public function index() {
        $this->load->model('account/customer');

        // Login override for admin users
        if (!empty($this->request->get['token'])) {

            $this->event->trigger('pre.customer.login');

            $this->customer->logout();
            $this->cart->clear();

            unset($this->session->data['wishlist']);
            unset($this->session->data['payment_address']);
            unset($this->session->data['payment_method']);
            unset($this->session->data['payment_methods']);
            unset($this->session->data['shipping_address']);
            unset($this->session->data['shipping_method']);
            unset($this->session->data['shipping_methods']);
            unset($this->session->data['comment']);
            unset($this->session->data['order_id']);
            unset($this->session->data['coupon']);
            unset($this->session->data['reward']);
            unset($this->session->data['voucher']);
            unset($this->session->data['vouchers']);

            $customer_info = $this->model_account_customer->getCustomerByToken($this->request->get['token']);

这是$this->request->get['token']是什么,它做了什么,这个令牌集在哪里?我如何var_dump看到它的价值?

1 个答案:

答案 0 :(得分:2)

在OpenCart中,管理员无需输入客户密码即可登录客户帐户。

在管理面板/销售/客户中,每个客户都有一个锁定图标和“登录商店”标题的链接,它正在调用此方法:sale/customer/login

管理\控制器\出售\ customer.php

public function login() {
    ...
    $token = md5(mt_rand());
    ...
    $this->response->redirect($store_info['url'] . 'index.php?route=account/login&token=' . $token);
    ...
}

enter image description here