Circular reference detected for services: application.2, security.user, 25_AdminModule_Model_UserManager. sear
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- kiCkZ
- Člen | 153
Nevíte někdo proč mi vyskakuje tato chyba:
Circular reference detected for services: application.2, security.user, 25_AdminModule_Model_UserManager. search►
namespace AdminModule\Model;
use Nette,
Nette\Security\Passwords;
class UserManager implements Nette\Security\IAuthenticator {
use Nette\SmartObject;
const
TABLE_NAME = 'users',
COLUMN_ID = 'id',
COLUMN_NAME = 'username',
COLUMN_PASSWORD_HASH = 'password',
COLUMN_EMAIL = 'email',
COLUMN_ROLE = 'role';
private $database;
private $user;
public function __construct(\Nette\Database\Context $database, \Nette\Security\User $user) {
$this->database = $database;
$this->user = $user;
}
public function update($values) {
$id = $this->user->getId();
$row = $this->database->table(self::TABLE_NAME)->where(self::COLUMN_ID,$id)->fetch();
if(!empty($values->password)) {
$verify = password_verify($password, $row['password']);
if($verify) {
$this->database->table(self::TABLE_NAME)->where(self::COLUMN_NAME,$id)->update([
self::COLUMN_NAME => $values->username,
self::COLUMN_PASSWORD_HASH => Passwords::hash($values->password),
self::COLUMN_EMAIL => $values->email,
]);
}
} else {
$this->database->table(self::TABLE_NAME)->where(self::COLUMN_ID,$id)->update([
self::COLUMN_NAME => $values->username,
self::COLUMN_EMAIL => $values->email,
]);
}
}
Díky
- kiCkZ
- Člen | 153
CZechBoY napsal(a):
Lepsi je predat id uzivatele primo do metody update jako parametr.
Zatím jsem to vyřešil tak, že jsem vytvořil nový model, kam jsem přesunul jen tu autentizaci (a implementaci Nette\Security\IAuthenticator) od UserManagera. A zatím to funguje, je to v pořádku ?
Editoval kiCkZ (18. 8. 2017 9:38)