Closed AyoubTorabi closed 5 years ago
Hi,
all imports (uses) are not mentionned in doc.
You must add in your BaseAUthController class
:
use Ubiquity\orm\DAO;
Error Message : Declaration of controllers\BaseAuthController::_isValidUser() must be compatible with Ubiquity\controllers\auth\AuthController::_isValidUser($action = NULL)
Fatal error: Uncaught TypeError: Return value of controllers\Admin::getAuthController() must be an instance of controllers\AuthController, instance of controllers\BaseAuthController returned in C:\Users\user\Desktop\PHP\pay\app\controllers\Admin.php:9 Stack trace: #0 C:\Users\user\Desktop\PHP\pay\vendor\phpmv\ubiquity\src\Ubiquity\controllers\auth\WithAuthTrait.php(83): controllers\Admin->getAuthController() #1 C:\Users\user\Desktop\PHP\pay\vendor\phpmv\ubiquity\src\Ubiquity\controllers\auth\WithAuthTrait.php(52): controllers\Admin->_getAuthController() #2 C:\Users\user\Desktop\PHP\pay\vendor\phpmv\ubiquity\src\Ubiquity\controllers\Startup.php(139): controllers\Admin->isValid('index') #3 C:\Users\user\Desktop\PHP\pay\vendor\phpmv\ubiquity\src\Ubiquity\controllers\Startup.php(30): Ubiquity\controllers\Startup::runAction(Array, true, true) #4 C:\Users\user\Desktop\PHP\pay\vendor\phpmv\ubiquity\src\Ubiquity\controllers\Startup.php(98): Ubiquity\controllers\Startup::_preRunAction(Array, true, true) #5 C:\Use in C:\Users\user\Desktop\PHP\pay\app\controllers\Admin.php on line 9 Admin.php <?php namespace controllers; use Ubiquity\controllers\admin\UbiquityMyAdminBaseController; use Ubiquity\controllers\auth\WithAuthTrait;
class Admin extends UbiquityMyAdminBaseController{ use WithAuthTrait; protected function getAuthController(): AuthController { return new BaseAuthController(); } }
@AyoubTorabi
There was an error in the guide about _isValidUser
The correct declaration is:
public function _isValidUser($action=null){}
Fixed in https://github.com/phpMv/ubiquity/issues/53
The documentation has been updated accordingly (see Guide Auth)
I had already added but did not work. Validation also does not appear in the /admin address. Code Source Address: https://justpaste.it/27ncd
This section(AUTH)and CRUD, if the bootstrap theme has been installed and active, will not load "Create Special Controller" button this notification on it "No scaffold with an active theme" Please test source code of example and share with me
It's still an import
issue.
You are missing the import of AuthController
use Ubiquity\controllers\auth\AuthController;
Admin controller:
namespace controllers;
use Ubiquity\controllers\admin\UbiquityMyAdminBaseController;
use Ubiquity\controllers\auth\AuthController;
use Ubiquity\controllers\auth\WithAuthTrait;
class Admin extends UbiquityMyAdminBaseController {
use WithAuthTrait;
protected function getAuthController(): AuthController {
return new BaseAuthController();
}
}
Indeed,
Auth
and CRUD
scaffolding sections are currently only available with Semantic-ui
The Auth scaffolding part is implemented in Ubiquity-demo project
Hello ,I encountered the following problem when i test scafolding->Auth https://micro-framework.readthedocs.io/en/latest/scaffolding/auth.html
Fatal error: Uncaught Error: Class 'controllers\DAO' not found in C:...\app\controllers\BaseAuthController.php:24 Stack trace: #0
MyBaseAuthController.php <?php namespace controllers; use Ubiquity\utils\http\USession; use Ubiquity\utils\http\URequest; /**
Auth Controller BaseAuthController **/ class BaseAuthController extends \Ubiquity\controllers\auth\AuthController{
protected function onConnect($connected) { $urlParts=$this->getOriginalURL(); USession::set($this->_getUserSessionKey(), $connected); if(isset($urlParts)){ Startup::forward(implode("/",$urlParts)); }else{ Startup::forward("admin"); } }
protected function _connect() { if(URequest::isPost()){ $email=URequest::post($this->_getLoginInputName()); $password=URequest::post($this->_getPasswordInputName()); return DAO::uGetOne(User::class, "email=? and password= ?",false,[$email,$password]); } return; }
/**
public function _getBaseRoute() { return 'BaseAuthController'; } /**
Admin.php <?php namespace controllers; use Ubiquity\controllers\admin\UbiquityMyAdminBaseController; use Ubiquity\controllers\auth\WithAuthTrait;
class Admin extends UbiquityMyAdminBaseController{ // Error with use WithAuthTrait; protected function getAuthController(): AuthController { return new BaseAuthController(); } }