Question

I started to learn CakePHP about month ago, so I'm pretty new to it and I would like to ask a question: How can I login using only barcode?

My plan is to make a login only with barcode for regular users and for admin login they would have regular username and password. I have searched many pages but I haven't yet find any solutions for this.

Was it helpful?

Solution

For the example QR-Code:

http://www.example.com/User/login?username=simon&password=12345

In Controller use this in login-action:

if ($this->request->is('get')) 
{
    $user = $this->User->find('first', array(
    'conditions' => array(
        'User.name' => $this->request->query['username'],
        'User.password' => $this->request->query['password'] // don´t forget to hash password here
    )));

    if ($user != null) 
    {
        $this->Auth->login($user);
        $this->redirect('/admin/index');
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top