User account query

hello I need to make a user account, how can I do it? and in what folders do you need to do this? srs / controller / appcontroller? or in srs / temlete? or in srs / controller / admin / userscontroler please tell me the code. thank.

<?php

namespace App\Controller;

use App\Controller\FrontController;
use Cake\Event\Event;

/**
 * @property \App\Model\Table\UsersTable $Users
 */
class UsersController extends FrontController
{
    public function initialize()
    {
        parent::initialize();
        $this->loadComponent('Cookie');
    }

    public function beforeFilter(Event $event)
    {
        parent::beforeFilter($event);
        $this->Auth->allow(['ref']);
    }

    public function ref($username = null)
    {
        $this->autoRender = false;

        if (!$username) {
            return $this->redirect('/');
        }

        $user = $this->Users->find()->where(['username' => $username, 'status' => 1])->first();

        if (!$user) {
            return $this->redirect('/');
        }
        
       
       

        $this->Cookie->configKey('ref', [
            'expires' => '+3 month',
            'httpOnly' => true,
            'encryption' => false
        ]);
        $this->Cookie->write('ref', $username);

        return $this->redirect('/');
    }
}

Hi @rsupiyev

Have you worked through the official tutorial? It explains all the basic CakePHP concepts, including how to create user accounts.

1 Like

HI, I have user editing on my site. deleting, deactivating, but I need to make banned users, how can I do this? banned users unban users? help me advice please

Answered already

How many times do you need an answer.

Please take a basic crud tutorial before you try any more endeavors.

A Status column