The Heart of Your Product

Documentation

Download in PDF

Download local copy of SCore docs in one file

ZF Documentation

Read It

Explore ZF manuals for native features

Table of Contents

Authorization

Singular Core provides two optional ways of authorization depending on specific task:

  1. Sungular_Core('Auth')->....
  2. Predefined auth controller from system module.

Using Singular_Core('Auth')

login($username, $password, $successRedirectURI = null);

$auth = Singular_Core::_('Auth');
if (!$this->login('username', 'password', '/success')) {
    // handle auth error
}

If authorization is success it's simply redirect to url you have provided in $successRedirectURI.

authenticate($username, $password);

$auth = Singular_Core::_('Auth');
/** @var $result Zend_Auth_Result */
$result = $auth->authenticate('username', 'password');
// Process auth result
switch ($result->getCode()) {
   case Zend_Auth_Result::FAILURE:
	// handle failure
       break;
   case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID
	// handle invalid credential
       break;

...........

   case Zend_Auth_Result::SUCCESS:
	// success code
       break;
}

Using system Auth controller

For using Auth controller from system module simply add "/login" action parameter to form.

In other words system route "login" forwards to system module, auth controller, login action.

Authorization form example:

errorMessage)): ?>

Specify "username" and "password" field. Hidden field "login_type" is not required but if available informs the controller to redirect if authorization is succeeds to appropriate area.

1 (Singular_Core_System_Controller_Auth::LOGIN_TYPE_ADMIN) — "admin_dashboard" route

2 (Singular_Core_System_Controller_Auth::LOGIN_TYPE_USER) — "frontend_home" route

If wasn't set (default value) redirect to "frontend_home" route.