1. Go to this page and download the library: Download crada/phalcon-user-plugin library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
crada / phalcon-user-plugin example snippets
$security = new \Phalcon\UserPlugin\Plugin\Security($di);
$eventsManager->attach('dispatch', $security);
use Phalcon\UserPlugin\Plugin\Security as SecurityPlugin;
use Phalcon\Mvc\Dispatcher;
$di->setShared(
'dispatcher',
function() use ($di) {
$eventsManager = $di->getShared('eventsManager');
$security = new SecurityPlugin($di);
$eventsManager->attach('dispatch', $security);
$dispatcher = new Dispatcher();
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
}
);
use Phalcon\UserPlugin\Auth\Auth;
use Phalcon\UserPlugin\Acl\Acl;
use Phalcon\UserPlugin\Mail\Mail;
$di->setShared(
'auth',
function() {
return new Auth();
}
);
$di->setShared(
'acl',
function() {
return new Acl();
}
);
$di->setShared(
'mail',
function() {
return new Mail();
}
);
class UserController extends Controller
{
/**
* Login user
* @return \Phalcon\Http\ResponseInterface
*/
public function loginAction()
{
if (true === $this->auth->isUserSignedIn()) {
$this->response->redirect(['action' => 'profile']);
}
$form = new LoginForm();
try {
$this->auth->login($form);
} catch (AuthException $e) {
$this->flash->error($e->getMessage());
}
$this->view->form = $form;
}
/**
* Login with Facebook account
*/
public function loginWithFacebookAction()
{
try {
$this->view->disable();
return $this->auth->loginWithFacebook();
} catch(AuthException $e) {
$this->flash->error('There was an error connectiong to Facebook.');
}
}
/**
* Login with LinkedIn account
*/
public function loginWithLinkedInAction()
{
try {
$this->view->disable();
$this->auth->loginWithLinkedIn();
} catch(AuthException $e) {
$this->flash->error('There was an error connectiong to LinkedIn.');
}
}
/**
* Login with Twitter account
*/
public function loginWithTwitterAction()
{
try {
$this->view->disable();
$this->auth->loginWithTwitter();
} catch(AuthException $e) {
$this->flash->error('There was an error connectiong to Twitter.');
}
}
/**
* Login with Google account
*/
public function loginWithGoogleAction()
{
try {
$this->view->disable();
$this->auth->loginWithGoogle();
} catch(AuthException $e) {
$this->flash->error('There was an error connectiong to Google.');
}
}
/**
* Logout user and clear the data from session
*
* @return \Phalcon\Http\ResponseInterface
*/
public function signoutAction()
{
$this->auth->remove();
return $this->response->redirect('/', true);
}
}
bash
$ php composer.phar update
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.