1. Go to this page and download the library: Download dez-php/phalcon-auth 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/ */
dez-php / phalcon-auth example snippets
$container = new \Phalcon\Di\FactoryDefault();
$container->set('auth', function(){
// Pass session adapter into Auth
$auth = new \PhalconDez\Auth\Auth(
new \PhalconDez\Auth\Adapter\Session()
);
// Pass empty instance of Credentials Model implement PhalconModel
$auth->setCredentialsModel(
new \PhalconDez\Auth\Model\Credentials()
);
// Pass empty instance of Session Model implement PhalconModel
$auth->setSessionModel(
new \PhalconDez\Auth\Model\Session()
);
// Run initialize
$auth->initialize();
return $auth;
});
if($auth->isUser() && $auth->getAdapter()->verifyPassword('qwerty') === true){
echo 'Password is corrected';
}
if($auth->isGuest() === true){
echo 'You are non-authorized user';
}
if($auth->isUser() === true){
echo 'You are authorized user';
}
if($auth->isUser() === true){
$userModel = $auth->getUser();
echo "Hello, {$userModel->getEmail()}. You was registered at {$userModel->getCreatedAt()}";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.