2017 © Pedro Peláez
 

library rapture-auth

Rapture Authentication component

image

iuliann/rapture-auth

Rapture Authentication component

  • Thursday, June 15, 2017
  • by iuliann
  • Repository
  • 1 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 50 % Grown

The README.md

Rapture PHP Authentication component

PhpVersion License, (*1)

Auth component uses interfaces to create the authentication logic: - UserInterface - user model main methods like getId, getName, isAuthenticated, isAnonymous - SourceInterface - user fetching method - StorageInterface - user storing (usually a session adapter), (*2)

Requirements

  • PHP v5.4

Install

composer require mrjulio/rapture-auth

Quick start

class User implements UserInterface, SourceInterface
{
    /*
     * SourceInterface
     */

    /**
     * @param array $data Authentication data
     *
     * @return $this
     */
    public function fetchUser($data)
    {
        $data += ['email' => null, 'password' => null];

        $user = UserQuery::create()->filterByEmail($data['email'])->findOne();

        if ($user && password_verify($data['password'], $user->getPassword())) {
            return $user;
        }

        return new self;
    }

    /*
     *  UserInterface
     */

    public function getId()
    {
        return $this->id;
    }

    /**
     * getName
     *
     * @return string
     */
    public function getName()
    {
        return $this->getFirstname();
    }

    /**
     * Check if user is anonymous
     *
     * @return bool
     */
    public function isAnonymous()
    {
        return (int)$this->getId() == 0;
    }

    /**
     * Check if user is authenticated
     *
     * @return bool
     */
    public function isAuthenticated()
    {
        return !$this->isAnonymous();
    }
}

About

Author

Iulian N. rapture@iuliann.ro, (*3)

Testing

cd ./test && phpunit

License

Rapture PHP Authentication is licensed under the MIT License - see the LICENSE file for details., (*4)

The Versions

15/06 2017

dev-master

9999999-dev http://rapture.iuliann.ro

Rapture Authentication component

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

library

15/06 2017

v1.0

1.0.0.0 http://rapture.iuliann.ro

Rapture Authentication component

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

library