Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Application\Authentication\Example;
- use Concrete\Core\Authentication\AuthenticationTypeController;
- use Concrete\Core\Authentication\AuthenticationTypeFailureException;
- use Concrete\Core\User\User;
- class Controller extends AuthenticationTypeController
- {
- public function getAuthenticationTypeIconHTML()
- {
- return "<i class='fa fa-bug'></i>";
- }
- public function view()
- {
- // blank
- }
- /**
- * @return string
- */
- public function getHandle()
- {
- return 'example';
- }
- /**
- * Method used to verify the user and log them in.
- * Returning user will cause finishAuthentication to run, otherwise it's expected that the subclass manage completion.
- *
- * @throws AuthenticationTypeFailureException
- *
- * @return \User|null
- */
- public function authenticate()
- {
- $password = $this->post('password');
- // If the password matches
- if ($password == 'foo') {
- $user = User::loginByUserID(1);
- } else {
- throw new \Exception('Invalid password.');
- }
- return $user;
- }
- /**
- * Method used to clean up.
- * This method must be defined, if it isn't needed, leave it blank.
- *
- * @param \User $u
- */
- public function deauthenticate(User $u)
- {
- // blank
- }
- /**
- * Test user authentication status.
- *
- * @param \User $u
- *
- * @return bool Returns true if user is authenticated, false if not
- */
- public function isAuthenticated(User $u)
- {
- return $u->isLoggedIn();
- }
- /**
- * Create a cookie hash to identify the user indefinitely.
- *
- * @param \User $u
- *
- * @return string Unique hash to be used to verify the users identity
- */
- public function buildHash(User $u)
- {
- return '';
- }
- /**
- * Verify cookie hash to identify user.
- *
- * @param $u User object requesting verification.
- * @param string $hash
- *
- * @return bool returns true if the hash is valid, false if not
- */
- public function verifyHash(User $u, $hash)
- {
- return true;
- }
- }
Add Comment
Please, Sign In to add comment