Skip to content

AuthManager Methods and Responses

Ryan Durham edited this page Jan 23, 2016 · 2 revisions

Below is an API reference for the Centaur AuthManager class. Many of these methods are wrappers for their corresponding Sentinel counterparts. To see examples of authManager usage you can take a look at the example controllers in this package.

Each method returns an instance of the Centaur\Replies\Reply class, which is essentially just a data transfer object with some convenient helper methods. There are three different types of Reply object: SuccessReply, FailureReply and ExceptionReply.

authenticate()

public function authenticate($credentials, $remember = false, $login = true)

  • $credentials: an array containing the credentials for the user attempting to authenticate. Usually this will be "Email" and "Password.
  • $remember: a boolean value indicated whether or not a "remember me" cookie should be created for this user.
  • $login: a boolean value indicating whether or not this user should be logged in once they have been authenticated. More often than not you will want this to be true.

Returns Centaur\Replies\Reply:

  • $reply->isSuccessful(): Returns true if the authentication was successful
  • $reply->getException(): If an exception was thrown, returns the exception object.
  • $reply->message: A helpful message that you can show you user, if you want.

logout()

public function logout(UserInterface $user = null, $everywhere = false)

  • $user: An instance of the user model to be logged out. If no user is specified, Sentinel will assume you want to log out the current user.
  • $everywhere: Sentinel supports multiple login sessions; passing true here will terminate all sessions for the given user.

Returns Centaur\Replies\Reply:

  • $reply->isSuccessful(): Returns true if the logout was successful
  • $reply->getException(): If an exception was thrown, returns the exception object. This is unlikely.
  • $reply->message: A helpful message that you can show you user, if you want.

register()

public function register(array $credentials, $activation = false)

  • $credentials: an array containing the credentials for the user attempting to authenticate. Usually this will be "Email" and "Password.
  • $activation: Passing a true value here will tell Sentinel to automatically activate the user once they have been created.

Returns Centaur\Replies\Reply:

  • $reply->isSuccessful(): Returns true if the logout was successful
  • $reply->getException(): If an exception was thrown, returns the exception object.
  • $reply->message: A helpful message that you can show you user, if you want.
  • $reply->user: The newly created user object
  • $reply->activation: The activation object for the new user. See more about Activations here.

activate()

public function activate($code)

  • $code: An activation code for the user we are trying to activate.

Returns Centaur\Replies\Reply:

  • $reply->isSuccessful(): Returns true if the logout was successful
  • $reply->getException(): If an exception was thrown, returns the exception object.
  • $reply->message: A helpful message that you can show you user, if you want.

resetPassword()

public function resetPassword($code, $password)

  • $code: A Reminder code for the user that is trying to reset their password
  • $password: The user's new password.

Returns Centaur\Replies\Reply:

  • $reply->isSuccessful(): Returns true if the logout was successful
  • $reply->getException(): If an exception was thrown, returns the exception object.
  • $reply->message: A helpful message that you can show you user, if you want.
Clone this wiki locally