Code to log user in after registration

Thank you for pointing me in the right direction.

Here is my code for anyone else that may have the same issue

	public function register()
	{
        $this->loadModel('Users');
		$user = $this->Users->newEmptyEntity();
        if ($this->request->is('post')) {
			
			$formdata = $this->request->getData();
			$formdata['role'] = 'user';
            
			$user = $this->Users->patchEntity($user, $formdata);
			
            if ($result = $this->Users->save($user)) {
				$this->Authentication->setIdentity($result);
				$this->Flash->success(__('The user has been saved.'));
                return $this->redirect(['action' => 'index']);
            }
            $this->Flash->error(__('The user could not be saved. Please, try again.'));
        }
        $this->set(compact('user'));
	}