This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($this->authManager->loggedIn()) { | |
// Do something | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @var \PhalconRest\Http\Request $request */ | |
$token = $this->request->getToken(); | |
if ($token) { | |
$this->authManager->authenticateToken($token); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @var \PhalconRest\Auth\Session $session */ | |
$session = $this->authManager->getSession(); | |
$response = [ | |
'token' => $session->getToken(), | |
'expires' => $session->getExpirationTime() | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Authenticate user using username and password (Username Account) | |
*/ | |
/** @var \PhalconRest\Auth\Manager $authManager */ | |
$session = $authManager->loginWithUsernamePassword(\App\Auth\UsernameAccountType::NAME, $username, $password); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Authenticate user | |
*/ | |
$eventsManager->attach('micro', new \PhalconRest\Middleware\Authentication); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Auth; | |
use App\Constants\Services; | |
use Phalcon\Di; | |
use PhalconRest\Auth\Manager; | |
class UsernameAccountType implements \PhalconRest\Auth\AccountType | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @description Phalcon - AuthManager | |
*/ | |
$di->setShared(AppServices::AUTH_MANAGER, function () use ($di, $config) { | |
$authManager = new \PhalconRest\Auth\Manager($config->authentication->expirationTime); | |
$authManager->registerAccountType(App\Auth\UsernameAccountType::NAME, new \App\Auth\UsernameAccountType()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
composer require redound/phalcon-rest "^1.2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cp app/configs/server.template.php app/configs/server.develop.php |