<?php
namespace mpcmf\modules\authex\controllers;

use mpcmf\modules\authex\mappers\inviteMapper;
use mpcmf\modules\moduleBase\controllers\controllerBase;
use mpcmf\modules\moduleBase\exceptions\mapperException;
use mpcmf\system\helper\io\codes;
use mpcmf\system\pattern\singleton;

/**
 * Class inviteController
 *
 * Invite system
 *
 *
  * @generated by mpcmf/codeManager
 *
 * @package mpcmf\modules\authex\controllers;
 * @date 2015-10-01 12:35:13
 *
 * @author Dmitry Emelyanov <gilberg.vrn@gmail.com>
 */
class inviteController
    extends controllerBase
{

    use singleton;

    public function _invite($invite)
    {
        try {
            inviteMapper::getInstance()->getBy([
                inviteMapper::FIELD__INVITE => $invite
            ]);
        } catch (mapperException $mapperException) {
            $message = $mapperException->getMessage();

            if (mb_strpos($message, 'not found') === false) {
                return self::error($mapperException->getMessage(), $mapperException->getCode(), codes::RESPONSE_CODE_NOT_FOUND);
            }

            return self::nothing([]);
        }

        $this->getSlim()->redirectTo('/authex/user/register', ['invite' => $invite]);

        return self::nothing([]);
    }
}
<?php
namespace mpcmf\modules\authex\controllers;

use mpcmf\modules\authex\mappers\inviteMapper;
use mpcmf\modules\moduleBase\controllers\controllerBase;
use mpcmf\modules\moduleBase\exceptions\mapperException;
use mpcmf\system\helper\io\codes;
use mpcmf\system\pattern\singleton;

/**
 * Class inviteController
 *
 * Invite system
 *
 *
  * @generated by mpcmf/codeManager
 *
 * @package mpcmf\modules\authex\controllers;
 * @date 2015-10-01 12:35:13
 *
 * @author Dmitry Emelyanov <gilberg.vrn@gmail.com>
 */
class inviteController
    extends controllerBase
{

    use singleton;

    public function _invite($invite)
    {
        try {
            inviteMapper::getInstance()->getBy([
                inviteMapper::FIELD__INVITE => $invite,
                inviteMapper::FIELD__USED => false,
            ]);
        } catch (mapperException $mapperException) {
            $message = $mapperException->getMessage();

            if (mb_strpos($message, 'not found') === false) {
                return self::error($mapperException->getMessage(), $mapperException->getCode(), codes::RESPONSE_CODE_NOT_FOUND);
            }

            return self::nothing([]);
        }

        $this->getSlim()->redirectTo('/authex/user/register', ['invite' => $invite]);

        return self::nothing([]);
    }
}
Add check for used invites
Add check for used invites
