-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to use it? Any demo? #27
Comments
At the moment there is a bug with the "master" repo, so you'll need to grab v2.0 via composer |
sorry, it's still report the error. 2015-09-15 12:38 GMT+08:00 Mike Guo [email protected]:
|
Could you share your project via github? My services.php looks something like this: $di = new FactoryDefault();
//Make config settings available
$di->set('config', $config, true);
/**
* Plugging the PhalconUserPlugin
*/
$di['dispatcher'] = function() use ($di) {
$eventsManager = $di->getShared('eventsManager');
$security = new \Phalcon\UserPlugin\Plugin\Security($di);
$eventsManager->attach('dispatch', $security);
$dispatcher = new Dispatcher();
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
};
/**
* Register Auth, ACL and Mail services used by PhalconUserPlugin
*/
$di['auth'] = function(){
return new \Phalcon\UserPlugin\Auth\Auth();
};
$di['acl'] = function() {
return new \Phalcon\UserPlugin\Acl\Acl();
};
$di['mail'] = function() {
return new \Phalcon\UserPlugin\Mail\Mail();
}; |
my project uses multiple model, and in Model.php, I insert the code: public function registerServices(DiInterface $di)
in the configuration file
} but when I insert these code, it's report: 2015-09-15 15:20 GMT+08:00 Carl [email protected]:
|
Now I edit the code like: /**
* Plugging the PhalconUserPlugin
*/
$di['auth'] = function(){
return new \Phalcon\UserPlugin\Auth\Auth();
};
$di['acl'] = function() {
return new \Phalcon\UserPlugin\Acl\Acl();
};
$di['mail'] = function() {
return new \Phalcon\UserPlugin\Mail\Mail();
};
$di['dispatcher'] = function() use ($di) {
$eventsManager = new \Phalcon\Events\Manager();
$security = new \Phalcon\UserPlugin\Plugin\Security($di);
$security->setView($di['view'])->setAuth($di['auth']);
$eventsManager->attach('dispatch', $security);
$dispatcher = new \Phalcon\Mvc\Dispatcher();
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
}; the error was fixed. seems like that Security.php lost initialize()? |
Did you remember to configure the 'pup' array in your config? It should look something like this: //Example of settings used by PhalconUserPlugin
'pup' => array(//[P]halcon[U]ser[P]lugin
'redirect' => array(
'success' => 'user/profile', //...redirect to this controller/action on success
'failure' => 'user/login' //... redirect here on auth failure
),
'resources' => array(
'type' => 'public',
'resources' => array(
'*' => array( // All except
'user' => array('account', 'profile') //...the actions "account" and "profile" are private
),
)
),
) |
Yes, I have add the config values when start to use it. |
Awesome! This thread help me a lot |
This solved my problem, thank you very much. |
when I insert
$di['dispatcher'] = function() use ($di) {
$eventsManager = $di->getShared('eventsManager');
$security = new \Phalcon\UserPlugin\Plugin\Security($di);
$eventsManager->attach('dispatch', $security);
to my project, it's report fatal error: Call to a member function hasRememberMe() on a non-object.
I need setAuth first? Could you uploads any demo how to use it? Thanks.
The text was updated successfully, but these errors were encountered: