├── .gitignore ├── .php_cs ├── .scrutinizer.yml ├── .travis.yml ├── LICENSE ├── Module.php ├── README.md ├── build ├── .gitignore └── logs │ └── .gitignore ├── composer.json ├── config ├── README.md ├── module.config.php └── zfcuser.global.php.dist ├── data ├── schema.mysql.sql ├── schema.pgsql.sql ├── schema.sql └── schema.sqlite.sql ├── src └── ZfcUser │ ├── Authentication │ ├── Adapter │ │ ├── AbstractAdapter.php │ │ ├── AdapterChain.php │ │ ├── AdapterChainEvent.php │ │ ├── AdapterChainServiceFactory.php │ │ ├── ChainableAdapter.php │ │ ├── Db.php │ │ └── Exception │ │ │ └── OptionsNotFoundException.php │ └── Storage │ │ └── Db.php │ ├── Controller │ ├── Plugin │ │ └── ZfcUserAuthentication.php │ ├── RedirectCallback.php │ └── UserController.php │ ├── Db │ └── Adapter │ │ ├── MasterSlaveAdapter.php │ │ └── MasterSlaveAdapterInterface.php │ ├── Entity │ ├── User.php │ └── UserInterface.php │ ├── EventManager │ └── EventProvider.php │ ├── Exception │ ├── AuthenticationEventException.php │ ├── DomainException.php │ └── ExceptionInterface.php │ ├── Factory │ ├── Authentication │ │ ├── Adapter │ │ │ └── DbFactory.php │ │ └── Storage │ │ │ └── DbFactory.php │ ├── AuthenticationService.php │ ├── Controller │ │ ├── Plugin │ │ │ └── ZfcUserAuthentication.php │ │ ├── RedirectCallbackFactory.php │ │ └── UserControllerFactory.php │ ├── Form │ │ ├── ChangeEmail.php │ │ ├── ChangePassword.php │ │ ├── Login.php │ │ └── Register.php │ ├── Mapper │ │ └── User.php │ ├── Options │ │ └── ModuleOptions.php │ ├── Service │ │ └── UserFactory.php │ ├── UserHydrator.php │ └── View │ │ └── Helper │ │ ├── ZfcUserDisplayName.php │ │ ├── ZfcUserIdentity.php │ │ └── ZfcUserLoginWidget.php │ ├── Form │ ├── Base.php │ ├── ChangeEmail.php │ ├── ChangeEmailFilter.php │ ├── ChangePassword.php │ ├── ChangePasswordFilter.php │ ├── Login.php │ ├── LoginFilter.php │ ├── ProvidesEventsForm.php │ ├── Register.php │ └── RegisterFilter.php │ ├── InputFilter │ └── ProvidesEventsInputFilter.php │ ├── Mapper │ ├── AbstractDbMapper.php │ ├── Exception │ │ ├── ExceptionInterface.php │ │ ├── InvalidArgumentException.php │ │ └── RuntimeException.php │ ├── User.php │ ├── UserHydrator.php │ └── UserInterface.php │ ├── Options │ ├── AuthenticationOptionsInterface.php │ ├── ModuleOptions.php │ ├── PasswordOptionsInterface.php │ ├── RegistrationOptionsInterface.php │ ├── UserControllerOptionsInterface.php │ └── UserServiceOptionsInterface.php │ ├── Service │ ├── Exception │ │ ├── ExceptionInterface.php │ │ └── InvalidArgumentException.php │ └── User.php │ ├── Validator │ ├── AbstractRecord.php │ ├── Exception │ │ ├── ExceptionInterface.php │ │ └── InvalidArgumentException.php │ ├── NoRecordExists.php │ └── RecordExists.php │ ├── View │ └── Helper │ │ ├── ZfcUserDisplayName.php │ │ ├── ZfcUserIdentity.php │ │ └── ZfcUserLoginWidget.php │ └── language │ ├── cs_CZ.mo │ ├── cs_CZ.po │ ├── de_DE.mo │ ├── de_DE.po │ ├── es_ES.mo │ ├── es_ES.po │ ├── fr_FR.mo │ ├── fr_FR.po │ ├── ja_JP.mo │ ├── ja_JP.po │ ├── msgIds.php │ ├── nl_NL.mo │ ├── nl_NL.po │ ├── pl_PL.mo │ ├── pl_PL.po │ ├── pt_BR.mo │ ├── pt_BR.po │ ├── ru_RU.mo │ └── ru_RU.po ├── tests ├── ZfcUserTest │ ├── Authentication │ │ ├── Adapter │ │ │ ├── AbstractAdapterTest.php │ │ │ ├── AdapterChainEventTest.php │ │ │ ├── AdapterChainServiceFactoryTest.php │ │ │ ├── AdapterChainTest.php │ │ │ ├── DbTest.php │ │ │ └── TestAsset │ │ │ │ └── AbstractAdapterExtension.php │ │ └── Storage │ │ │ └── DbTest.php │ ├── Controller │ │ ├── Plugin │ │ │ └── ZfcUserAuthenticationTest.php │ │ ├── RedirectCallbackTest.php │ │ └── UserControllerTest.php │ ├── Entity │ │ └── UserTest.php │ ├── Factory │ │ └── Form │ │ │ ├── ChangeEmailFormFactoryTest.php │ │ │ ├── ChangePasswordFormFactoryTest.php │ │ │ ├── LoginFormFactoryTest.php │ │ │ └── RegisterFormFactoryTest.php │ ├── Form │ │ ├── BaseTest.php │ │ ├── ChangeEmailFilterTest.php │ │ ├── ChangeEmailTest.php │ │ ├── ChangePasswordFilterTest.php │ │ ├── ChangePasswordTest.php │ │ ├── LoginFilterTest.php │ │ ├── LoginTest.php │ │ ├── RegisterFilterTest.php │ │ └── RegisterTest.php │ ├── Mapper │ │ ├── UserHydratorTest.php │ │ ├── UserTest.php │ │ └── _files │ │ │ └── user.sql │ ├── Options │ │ └── ModuleOptionsTest.php │ ├── Service │ │ └── UserTest.php │ ├── Validator │ │ ├── AbstractRecordTest.php │ │ ├── NoRecordExistsTest.php │ │ ├── RecordExistsTest.php │ │ └── TestAsset │ │ │ └── AbstractRecordExtension.php │ └── View │ │ └── Helper │ │ ├── ZfcUserDisplayNameTest.php │ │ ├── ZfcUserIdentityTest.php │ │ └── ZfcUserLoginWidgetTest.php ├── bootstrap.php ├── configuration.php.dist └── phpunit.xml └── view └── zfc-user └── user ├── _form.phtml ├── changeemail.phtml ├── changepassword.phtml ├── index.phtml ├── login.phtml └── register.phtml /.gitignore: -------------------------------------------------------------------------------- 1 | composer.lock 2 | vendor/* -------------------------------------------------------------------------------- /.php_cs: -------------------------------------------------------------------------------- 1 | name('*.phtml') 4 | ->notName('autoload_classmap.php') 5 | ->notName('README.md') 6 | ->notName('.php_cs') 7 | ->in(__DIR__); 8 | 9 | return Symfony\CS\Config\Config::create() 10 | ->finder($finder); 11 | -------------------------------------------------------------------------------- /.scrutinizer.yml: -------------------------------------------------------------------------------- 1 | imports: 2 | - php 3 | 4 | tools: 5 | php_cpd: true 6 | php_pdepend: true 7 | external_code_coverage: true -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.5 5 | - 5.6 6 | - 7.0 7 | - hhvm 8 | 9 | before_script: 10 | - composer self-update 11 | - composer install --dev --prefer-source; 12 | - wget https://scrutinizer-ci.com/ocular.phar 13 | - mysql -e "create database IF NOT EXISTS zfc_user;" -uroot 14 | 15 | script: 16 | - ./vendor/bin/phpunit --bootstrap=tests/bootstrap.php 17 | - ./vendor/bin/phpcs -n --standard=PSR2 ./src/ ./tests/ 18 | 19 | after_script: 20 | - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml 21 | 22 | notifications: 23 | email: false 24 | irc: "irc.freenode.org#zftalk.dev" 25 | 26 | matrix: 27 | fast_finish: true 28 | allow_failures: 29 | - php: hhvm 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, ZF-Commons Contributors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | Neither the name of the ZF-Commons nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /Module.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'zfcUserAuthentication' => \ZfcUser\Factory\Controller\Plugin\ZfcUserAuthentication::class, 26 | ), 27 | ); 28 | } 29 | 30 | public function getControllerConfig() 31 | { 32 | return array( 33 | 'factories' => array( 34 | 'zfcuser' => \ZfcUser\Factory\Controller\UserControllerFactory::class, 35 | ), 36 | ); 37 | } 38 | 39 | public function getViewHelperConfig() 40 | { 41 | return array( 42 | 'factories' => array( 43 | 'zfcUserDisplayName' => \ZfcUser\Factory\View\Helper\ZfcUserDisplayName::class, 44 | 'zfcUserIdentity' => \ZfcUser\Factory\View\Helper\ZfcUserIdentity::class, 45 | 'zfcUserLoginWidget' => \ZfcUser\Factory\View\Helper\ZfcUserLoginWidget::class, 46 | ), 47 | ); 48 | 49 | } 50 | 51 | public function getServiceConfig() 52 | { 53 | return array( 54 | 'aliases' => array( 55 | 'zfcuser_zend_db_adapter' => \Zend\Db\Adapter\Adapter::class, 56 | ), 57 | 'invokables' => array( 58 | 'zfcuser_register_form_hydrator' => \Zend\Hydrator\ClassMethods::class, 59 | ), 60 | 'factories' => array( 61 | 'zfcuser_redirect_callback' => \ZfcUser\Factory\Controller\RedirectCallbackFactory::class, 62 | 'zfcuser_module_options' => \ZfcUser\Factory\Options\ModuleOptions::class, 63 | 'ZfcUser\Authentication\Adapter\AdapterChain' => \ZfcUser\Authentication\Adapter\AdapterChainServiceFactory::class, 64 | 65 | // We alias this one because it's ZfcUser's instance of 66 | // Zend\Authentication\AuthenticationService. We don't want to 67 | // hog the FQCN service alias for a Zend\* class. 68 | 'zfcuser_auth_service' => \ZfcUser\Factory\AuthenticationService::class, 69 | 70 | 'zfcuser_user_hydrator' => \ZfcUser\Factory\UserHydrator::class, 71 | 'zfcuser_user_mapper' => \ZfcUser\Factory\Mapper\User::class, 72 | 73 | 'zfcuser_login_form' => \ZfcUser\Factory\Form\Login::class, 74 | 'zfcuser_register_form' => \ZfcUser\Factory\Form\Register::class, 75 | 'zfcuser_change_password_form' => \ZfcUser\Factory\Form\ChangePassword::class, 76 | 'zfcuser_change_email_form' => \ZfcUser\Factory\Form\ChangeEmail::class, 77 | 78 | 'ZfcUser\Authentication\Adapter\Db' => \ZfcUser\Factory\Authentication\Adapter\DbFactory::class, 79 | 'ZfcUser\Authentication\Storage\Db' => \ZfcUser\Factory\Authentication\Storage\DbFactory::class, 80 | 81 | 'zfcuser_user_service' => \ZfcUser\Factory\Service\UserFactory::class, 82 | ), 83 | ); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !logs 3 | !.gitignore 4 | !coverage-checker.php -------------------------------------------------------------------------------- /build/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zf-commons/zfc-user", 3 | "description": "A generic user registration and authentication module for ZF2. Supports Zend\\Db and Doctrine2.", 4 | "type": "library", 5 | "license": "BSD-3-Clause", 6 | "keywords": [ 7 | "zf2" 8 | ], 9 | "homepage": "https://github.com/ZF-Commons/ZfcUser", 10 | "authors": [ 11 | { 12 | "name": "Evan Coury", 13 | "email": "me@evancoury.com", 14 | "homepage": "http://blog.evan.pro/" 15 | }, 16 | { 17 | "name": "Kyle Spraggs", 18 | "email": "theman@spiffyjr.me", 19 | "homepage": "http://www.spiffyjr.me/" 20 | } 21 | ], 22 | "extra": { 23 | "branch-alias": { 24 | "dev-master": "0.1.x-dev" 25 | } 26 | }, 27 | "require": { 28 | "php": "^5.5|^7.0", 29 | "zendframework/zend-authentication": "^2.5", 30 | "zendframework/zend-crypt": "^3.0", 31 | "zendframework/zend-form": "^2.9", 32 | "zendframework/zend-inputfilter": "^2.7", 33 | "zendframework/zend-loader": "^2.5", 34 | "zendframework/zend-modulemanager": "^2.7", 35 | "zendframework/zend-mvc": "^3.0", 36 | "zendframework/zend-servicemanager": "^3.0", 37 | "zendframework/zend-stdlib": "^3.0", 38 | "zendframework/zend-validator": "^2.8", 39 | "zendframework/zend-db": "^2.8", 40 | "zendframework/zend-view": "^2.8", 41 | "zendframework/zend-session" : "^2.7", 42 | "zendframework/zend-http" : "^2.5", 43 | "zendframework/zend-mvc-plugin-flashmessenger": "^1.0", 44 | "zendframework/zend-i18n": "^2.7", 45 | "zendframework/zend-mvc-plugin-prg": "^1.0", 46 | "zendframework/zend-hydrator": "^2.0" 47 | }, 48 | "require-dev" : { 49 | "phpunit/phpunit" : ">=3.7,<4", 50 | "phpmd/phpmd" : "1.4.*", 51 | "squizlabs/php_codesniffer" : "1.4.*", 52 | "zendframework/zend-captcha" : "^2.6" 53 | }, 54 | "suggest": { 55 | "zendframework/zend-captcha" : "Zend\\Captcha if you want to use the captcha component" 56 | }, 57 | "autoload": { 58 | "psr-0": { 59 | "ZfcUser": "src/" 60 | }, 61 | "classmap": [ 62 | "./Module.php" 63 | ] 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /config/README.md: -------------------------------------------------------------------------------- 1 | DO NOT EDIT THE CONFIG FILES DIRECTLY IN THIS DIRECTORY! 2 | -------------------------------------------------------- 3 | 4 | Copy the dist file into your `./config/autoload` directory. (Remove the .dist 5 | part) 6 | -------------------------------------------------------------------------------- /config/module.config.php: -------------------------------------------------------------------------------- 1 | array( 5 | 'template_path_stack' => array( 6 | 'zfcuser' => __DIR__ . '/../view', 7 | ), 8 | ), 9 | 10 | 'router' => array( 11 | 'routes' => array( 12 | 'zfcuser' => array( 13 | 'type' => 'Literal', 14 | 'priority' => 1000, 15 | 'options' => array( 16 | 'route' => '/user', 17 | 'defaults' => array( 18 | 'controller' => 'zfcuser', 19 | 'action' => 'index', 20 | ), 21 | ), 22 | 'may_terminate' => true, 23 | 'child_routes' => array( 24 | 'login' => array( 25 | 'type' => 'Literal', 26 | 'options' => array( 27 | 'route' => '/login', 28 | 'defaults' => array( 29 | 'controller' => 'zfcuser', 30 | 'action' => 'login', 31 | ), 32 | ), 33 | ), 34 | 'authenticate' => array( 35 | 'type' => 'Literal', 36 | 'options' => array( 37 | 'route' => '/authenticate', 38 | 'defaults' => array( 39 | 'controller' => 'zfcuser', 40 | 'action' => 'authenticate', 41 | ), 42 | ), 43 | ), 44 | 'logout' => array( 45 | 'type' => 'Literal', 46 | 'options' => array( 47 | 'route' => '/logout', 48 | 'defaults' => array( 49 | 'controller' => 'zfcuser', 50 | 'action' => 'logout', 51 | ), 52 | ), 53 | ), 54 | 'register' => array( 55 | 'type' => 'Literal', 56 | 'options' => array( 57 | 'route' => '/register', 58 | 'defaults' => array( 59 | 'controller' => 'zfcuser', 60 | 'action' => 'register', 61 | ), 62 | ), 63 | ), 64 | 'changepassword' => array( 65 | 'type' => 'Literal', 66 | 'options' => array( 67 | 'route' => '/change-password', 68 | 'defaults' => array( 69 | 'controller' => 'zfcuser', 70 | 'action' => 'changepassword', 71 | ), 72 | ), 73 | ), 74 | 'changeemail' => array( 75 | 'type' => 'Literal', 76 | 'options' => array( 77 | 'route' => '/change-email', 78 | 'defaults' => array( 79 | 'controller' => 'zfcuser', 80 | 'action' => 'changeemail', 81 | ), 82 | ), 83 | ), 84 | ), 85 | ), 86 | ), 87 | ), 88 | ); 89 | -------------------------------------------------------------------------------- /data/schema.mysql.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `user` 2 | ( 3 | `user_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 4 | `username` VARCHAR(255) DEFAULT NULL UNIQUE, 5 | `email` VARCHAR(255) DEFAULT NULL UNIQUE, 6 | `display_name` VARCHAR(50) DEFAULT NULL, 7 | `password` VARCHAR(128) NOT NULL, 8 | `state` SMALLINT UNSIGNED 9 | ) ENGINE=InnoDB CHARSET="utf8"; 10 | -------------------------------------------------------------------------------- /data/schema.pgsql.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE public.user 2 | ( 3 | user_id serial NOT NULL, 4 | username character varying(255) DEFAULT NULL UNIQUE, 5 | email character varying(255) DEFAULT NULL UNIQUE, 6 | display_name character varying(50) DEFAULT NULL, 7 | password character varying(128) NOT NULL, 8 | state smallint, 9 | 10 | CONSTRAINT user_pkey PRIMARY KEY (user_id), 11 | CONSTRAINT user_username_key UNIQUE (username), 12 | CONSTRAINT user_email_key UNIQUE (email) 13 | ); 14 | -------------------------------------------------------------------------------- /data/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE user 2 | ( 3 | user_id INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL, 4 | username VARCHAR(255) DEFAULT NULL UNIQUE, 5 | email VARCHAR(255) DEFAULT NULL UNIQUE, 6 | display_name VARCHAR(50) DEFAULT NULL, 7 | password VARCHAR(128) NOT NULL, 8 | state SMALLINT 9 | ) ENGINE=InnoDB; 10 | -------------------------------------------------------------------------------- /data/schema.sqlite.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE user 2 | ( 3 | user_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 4 | username VARCHAR(255) DEFAULT NULL UNIQUE, 5 | email VARCHAR(255) DEFAULT NULL UNIQUE, 6 | display_name VARCHAR(50) DEFAULT NULL, 7 | password VARCHAR(128) NOT NULL, 8 | state SMALLINT 9 | ); 10 | -------------------------------------------------------------------------------- /src/ZfcUser/Authentication/Adapter/AbstractAdapter.php: -------------------------------------------------------------------------------- 1 | storage) { 24 | $this->setStorage(new Storage\Session(get_class($this))); 25 | } 26 | 27 | return $this->storage; 28 | } 29 | 30 | /** 31 | * Sets the persistent storage handler 32 | * 33 | * @param Storage\StorageInterface $storage 34 | * @return AbstractAdapter Provides a fluent interface 35 | */ 36 | public function setStorage(Storage\StorageInterface $storage) 37 | { 38 | $this->storage = $storage; 39 | return $this; 40 | } 41 | 42 | /** 43 | * Check if this adapter is satisfied or not 44 | * 45 | * @return bool 46 | */ 47 | public function isSatisfied() 48 | { 49 | $storage = $this->getStorage()->read(); 50 | return (isset($storage['is_satisfied']) && true === $storage['is_satisfied']); 51 | } 52 | 53 | /** 54 | * Set if this adapter is satisfied or not 55 | * 56 | * @param bool $bool 57 | * @return AbstractAdapter 58 | */ 59 | public function setSatisfied($bool = true) 60 | { 61 | $storage = $this->getStorage()->read() ?: array(); 62 | $storage['is_satisfied'] = $bool; 63 | $this->getStorage()->write($storage); 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/ZfcUser/Authentication/Adapter/AdapterChain.php: -------------------------------------------------------------------------------- 1 | getEvent(); 31 | 32 | $result = new AuthenticationResult( 33 | $e->getCode(), 34 | $e->getIdentity(), 35 | $e->getMessages() 36 | ); 37 | 38 | $this->resetAdapters(); 39 | 40 | return $result; 41 | } 42 | 43 | /** 44 | * prepareForAuthentication 45 | * 46 | * @param Request $request 47 | * @return Response|bool 48 | * @throws Exception\AuthenticationEventException 49 | */ 50 | public function prepareForAuthentication(Request $request) 51 | { 52 | $e = $this->getEvent(); 53 | $e->setRequest($request); 54 | 55 | $e->setName('authenticate.pre'); 56 | $this->getEventManager()->triggerEvent($e); 57 | 58 | $e->setName('authenticate'); 59 | $result = $this->getEventManager()->triggerEventUntil(function ($test) { 60 | return ($test instanceof Response); 61 | }, $e); 62 | 63 | if ($result->stopped()) { 64 | if ($result->last() instanceof Response) { 65 | return $result->last(); 66 | } 67 | 68 | throw new Exception\AuthenticationEventException( 69 | sprintf( 70 | 'Auth event was stopped without a response. Got "%s" instead', 71 | is_object($result->last()) ? get_class($result->last()) : gettype($result->last()) 72 | ) 73 | ); 74 | } 75 | 76 | if ($e->getIdentity()) { 77 | $e->setName('authenticate.success'); 78 | $this->getEventManager()->triggerEvent($e); 79 | return true; 80 | } 81 | 82 | $e->setName('authenticate.fail'); 83 | $this->getEventManager()->triggerEvent($e); 84 | 85 | return false; 86 | } 87 | 88 | /** 89 | * resetAdapters 90 | * 91 | * @return AdapterChain 92 | */ 93 | public function resetAdapters() 94 | { 95 | $sharedManager = $this->getEventManager()->getSharedManager(); 96 | 97 | if ($sharedManager) { 98 | $listeners = $sharedManager->getListeners(['authenticate'], 'authenticate'); 99 | foreach ($listeners as $listener) { 100 | if (is_array($listener) && $listener[0] instanceof ChainableAdapter) { 101 | $listener[0]->getStorage()->clear(); 102 | } 103 | } 104 | } 105 | 106 | return $this; 107 | } 108 | 109 | /** 110 | * logoutAdapters 111 | * 112 | * @return AdapterChain 113 | */ 114 | public function logoutAdapters() 115 | { 116 | //Adapters might need to perform additional cleanup after logout 117 | $e = $this->getEvent(); 118 | $e->setName('logout'); 119 | $this->getEventManager()->triggerEvent($e); 120 | } 121 | 122 | /** 123 | * Get the auth event 124 | * 125 | * @return AdapterChainEvent 126 | */ 127 | public function getEvent() 128 | { 129 | if (null === $this->event) { 130 | $this->setEvent(new AdapterChainEvent); 131 | $this->event->setTarget($this); 132 | } 133 | 134 | return $this->event; 135 | } 136 | 137 | /** 138 | * Set an event to use during dispatch 139 | * 140 | * By default, will re-cast to AdapterChainEvent if another event type is provided. 141 | * 142 | * @param Event $e 143 | * @return AdapterChain 144 | */ 145 | public function setEvent(Event $e) 146 | { 147 | if (!$e instanceof AdapterChainEvent) { 148 | $eventParams = $e->getParams(); 149 | $e = new AdapterChainEvent(); 150 | $e->setParams($eventParams); 151 | } 152 | 153 | $this->event = $e; 154 | 155 | return $this; 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/ZfcUser/Authentication/Adapter/AdapterChainEvent.php: -------------------------------------------------------------------------------- 1 | getParam('identity'); 18 | } 19 | 20 | /** 21 | * setIdentity 22 | * 23 | * @param mixed $identity 24 | * @return AdapterChainEvent 25 | */ 26 | public function setIdentity($identity = null) 27 | { 28 | if (null === $identity) { 29 | // Setting the identity to null resets the code and messages. 30 | $this->setCode(); 31 | $this->setMessages(); 32 | } 33 | $this->setParam('identity', $identity); 34 | return $this; 35 | } 36 | 37 | /** 38 | * getCode 39 | * 40 | * @return int 41 | */ 42 | public function getCode() 43 | { 44 | return $this->getParam('code'); 45 | } 46 | 47 | /** 48 | * setCode 49 | * 50 | * @param int $code 51 | * @return AdapterChainEvent 52 | */ 53 | public function setCode($code = null) 54 | { 55 | $this->setParam('code', $code); 56 | return $this; 57 | } 58 | 59 | /** 60 | * getMessages 61 | * 62 | * @return array 63 | */ 64 | public function getMessages() 65 | { 66 | return $this->getParam('messages') ?: array(); 67 | } 68 | 69 | /** 70 | * setMessages 71 | * 72 | * @param array $messages 73 | * @return AdapterChainEvent 74 | */ 75 | public function setMessages($messages = array()) 76 | { 77 | $this->setParam('messages', $messages); 78 | return $this; 79 | } 80 | 81 | /** 82 | * getRequest 83 | * 84 | * @return Request 85 | */ 86 | public function getRequest() 87 | { 88 | return $this->getParam('request'); 89 | } 90 | 91 | /** 92 | * setRequest 93 | * 94 | * @param Request $request 95 | * @return AdapterChainEvent 96 | */ 97 | public function setRequest(Request $request) 98 | { 99 | $this->setParam('request', $request); 100 | $this->request = $request; 101 | return $this; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/ZfcUser/Authentication/Adapter/AdapterChainServiceFactory.php: -------------------------------------------------------------------------------- 1 | setEventManager($serviceLocator->get('EventManager')); 20 | 21 | $options = $this->getOptions($serviceLocator); 22 | 23 | //iterate and attach multiple adapters and events if offered 24 | foreach ($options->getAuthAdapters() as $priority => $adapterName) { 25 | $adapter = $serviceLocator->get($adapterName); 26 | 27 | if (is_callable(array($adapter, 'authenticate'))) { 28 | $chain->getEventManager()->attach('authenticate', array($adapter, 'authenticate'), $priority); 29 | } 30 | 31 | if (is_callable(array($adapter, 'logout'))) { 32 | $chain->getEventManager()->attach('logout', array($adapter, 'logout'), $priority); 33 | } 34 | } 35 | 36 | return $chain; 37 | } 38 | 39 | /** 40 | * @var ModuleOptions 41 | */ 42 | protected $options; 43 | 44 | public function createService(ServiceLocatorInterface $serviceLocator) 45 | { 46 | $this->__invoke($serviceLocator, null); 47 | } 48 | 49 | 50 | /** 51 | * set options 52 | * 53 | * @param ModuleOptions $options 54 | * @return AdapterChainServiceFactory 55 | */ 56 | public function setOptions(ModuleOptions $options) 57 | { 58 | $this->options = $options; 59 | return $this; 60 | } 61 | 62 | /** 63 | * get options 64 | * 65 | * @param ServiceLocatorInterface $serviceLocator (optional) Service Locator 66 | * @return ModuleOptions $options 67 | * @throws OptionsNotFoundException If options tried to retrieve without being set but no SL was provided 68 | */ 69 | public function getOptions(ServiceLocatorInterface $serviceLocator = null) 70 | { 71 | if (!$this->options) { 72 | if (!$serviceLocator) { 73 | throw new OptionsNotFoundException( 74 | 'Options were tried to retrieve but not set ' . 75 | 'and no service locator was provided' 76 | ); 77 | } 78 | 79 | $this->setOptions($serviceLocator->get('zfcuser_module_options')); 80 | } 81 | 82 | return $this->options; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/ZfcUser/Authentication/Adapter/ChainableAdapter.php: -------------------------------------------------------------------------------- 1 | getStorage()->isEmpty()) { 43 | return true; 44 | } 45 | $identity = $this->getStorage()->read(); 46 | if ($identity === null) { 47 | $this->clear(); 48 | return true; 49 | } 50 | 51 | return false; 52 | } 53 | 54 | /** 55 | * Returns the contents of storage 56 | * 57 | * Behavior is undefined when storage is empty. 58 | * 59 | * @throws \Zend\Authentication\Exception\InvalidArgumentException If reading contents from storage is impossible 60 | * @return mixed 61 | */ 62 | public function read() 63 | { 64 | if (null !== $this->resolvedIdentity) { 65 | return $this->resolvedIdentity; 66 | } 67 | 68 | $identity = $this->getStorage()->read(); 69 | 70 | if (is_int($identity) || is_scalar($identity)) { 71 | $identity = $this->getMapper()->findById($identity); 72 | } 73 | 74 | if ($identity) { 75 | $this->resolvedIdentity = $identity; 76 | } else { 77 | $this->resolvedIdentity = null; 78 | } 79 | 80 | return $this->resolvedIdentity; 81 | } 82 | 83 | /** 84 | * Writes $contents to storage 85 | * 86 | * @param mixed $contents 87 | * @throws \Zend\Authentication\Exception\InvalidArgumentException If writing $contents to storage is impossible 88 | * @return void 89 | */ 90 | public function write($contents) 91 | { 92 | $this->resolvedIdentity = null; 93 | $this->getStorage()->write($contents); 94 | } 95 | 96 | /** 97 | * Clears contents from storage 98 | * 99 | * @throws \Zend\Authentication\Exception\InvalidArgumentException If clearing contents from storage is impossible 100 | * @return void 101 | */ 102 | public function clear() 103 | { 104 | $this->resolvedIdentity = null; 105 | $this->getStorage()->clear(); 106 | } 107 | 108 | /** 109 | * getStorage 110 | * 111 | * @return Storage\StorageInterface 112 | */ 113 | public function getStorage() 114 | { 115 | if (null === $this->storage) { 116 | $this->setStorage(new Storage\Session); 117 | } 118 | return $this->storage; 119 | } 120 | 121 | /** 122 | * setStorage 123 | * 124 | * @param Storage\StorageInterface $storage 125 | * @access public 126 | * @return Db 127 | */ 128 | public function setStorage(Storage\StorageInterface $storage) 129 | { 130 | $this->storage = $storage; 131 | return $this; 132 | } 133 | 134 | /** 135 | * getMapper 136 | * 137 | * @return UserMapper 138 | */ 139 | public function getMapper() 140 | { 141 | if (null === $this->mapper) { 142 | $this->mapper = $this->getServiceManager()->get('zfcuser_user_mapper'); 143 | } 144 | return $this->mapper; 145 | } 146 | 147 | /** 148 | * setMapper 149 | * 150 | * @param UserMapper $mapper 151 | * @return Db 152 | */ 153 | public function setMapper(UserMapper $mapper) 154 | { 155 | $this->mapper = $mapper; 156 | return $this; 157 | } 158 | 159 | /** 160 | * Retrieve service manager instance 161 | * 162 | * @return ServiceManager 163 | */ 164 | public function getServiceManager() 165 | { 166 | return $this->serviceManager; 167 | } 168 | 169 | /** 170 | * Set service manager instance 171 | * 172 | * @param ContainerInterface $locator 173 | * @return void 174 | */ 175 | public function setServiceManager(ContainerInterface $serviceManager) 176 | { 177 | $this->serviceManager = $serviceManager; 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /src/ZfcUser/Controller/Plugin/ZfcUserAuthentication.php: -------------------------------------------------------------------------------- 1 | getAuthService()->hasIdentity(); 35 | } 36 | 37 | /** 38 | * Proxy convenience method 39 | * 40 | * @return mixed 41 | */ 42 | public function getIdentity() 43 | { 44 | return $this->getAuthService()->getIdentity(); 45 | } 46 | 47 | /** 48 | * Get authAdapter. 49 | * 50 | * @return ZfcUserAuthentication 51 | */ 52 | public function getAuthAdapter() 53 | { 54 | return $this->authAdapter; 55 | } 56 | 57 | /** 58 | * Set authAdapter. 59 | * 60 | * @param authAdapter $authAdapter 61 | */ 62 | public function setAuthAdapter(AuthAdapter $authAdapter) 63 | { 64 | $this->authAdapter = $authAdapter; 65 | return $this; 66 | } 67 | 68 | /** 69 | * Get authService. 70 | * 71 | * @return AuthenticationService 72 | */ 73 | public function getAuthService() 74 | { 75 | return $this->authService; 76 | } 77 | 78 | /** 79 | * Set authService. 80 | * 81 | * @param AuthenticationService $authService 82 | */ 83 | public function setAuthService(AuthenticationService $authService) 84 | { 85 | $this->authService = $authService; 86 | return $this; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/ZfcUser/Controller/RedirectCallback.php: -------------------------------------------------------------------------------- 1 | router = $router; 34 | $this->application = $application; 35 | $this->options = $options; 36 | } 37 | 38 | /** 39 | * @return Response 40 | */ 41 | public function __invoke() 42 | { 43 | $routeMatch = $this->application->getMvcEvent()->getRouteMatch(); 44 | $redirect = $this->getRedirect($routeMatch->getMatchedRouteName(), $this->getRedirectRouteFromRequest()); 45 | 46 | $response = $this->application->getResponse(); 47 | $response->getHeaders()->addHeaderLine('Location', $redirect); 48 | $response->setStatusCode(302); 49 | return $response; 50 | } 51 | 52 | /** 53 | * Return the redirect from param. 54 | * First checks GET then POST 55 | * @return string 56 | */ 57 | private function getRedirectRouteFromRequest() 58 | { 59 | $request = $this->application->getRequest(); 60 | $redirect = $request->getQuery('redirect'); 61 | if ($redirect && $this->routeExists($redirect)) { 62 | return $redirect; 63 | } 64 | 65 | $redirect = $request->getPost('redirect'); 66 | if ($redirect && $this->routeExists($redirect)) { 67 | return $redirect; 68 | } 69 | 70 | return false; 71 | } 72 | 73 | /** 74 | * @param $route 75 | * @return bool 76 | */ 77 | private function routeExists($route) 78 | { 79 | try { 80 | $this->router->assemble(array(), array('name' => $route)); 81 | } catch (Exception\RuntimeException $e) { 82 | return false; 83 | } 84 | return true; 85 | } 86 | 87 | /** 88 | * Returns the url to redirect to based on current route. 89 | * If $redirect is set and the option to use redirect is set to true, it will return the $redirect url. 90 | * 91 | * @param string $currentRoute 92 | * @param bool $redirect 93 | * @return mixed 94 | */ 95 | protected function getRedirect($currentRoute, $redirect = false) 96 | { 97 | $useRedirect = $this->options->getUseRedirectParameterIfPresent(); 98 | $routeExists = ($redirect && $this->routeExists($redirect)); 99 | if (!$useRedirect || !$routeExists) { 100 | $redirect = false; 101 | } 102 | 103 | switch ($currentRoute) { 104 | case 'zfcuser/register': 105 | case 'zfcuser/login': 106 | case 'zfcuser/authenticate': 107 | $route = ($redirect) ?: $this->options->getLoginRedirectRoute(); 108 | return $this->router->assemble(array(), array('name' => $route)); 109 | break; 110 | case 'zfcuser/logout': 111 | $route = ($redirect) ?: $this->options->getLogoutRedirectRoute(); 112 | return $this->router->assemble(array(), array('name' => $route)); 113 | break; 114 | default: 115 | return $this->router->assemble(array(), array('name' => 'zfcuser')); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/ZfcUser/Db/Adapter/MasterSlaveAdapter.php: -------------------------------------------------------------------------------- 1 | slaveAdapter = $slaveAdapter; 29 | parent::__construct($driver, $platform, $queryResultPrototype); 30 | } 31 | /** 32 | * get slave adapter 33 | * 34 | * @return Adapter 35 | */ 36 | public function getSlaveAdapter() 37 | { 38 | return $this->slaveAdapter; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/ZfcUser/Db/Adapter/MasterSlaveAdapterInterface.php: -------------------------------------------------------------------------------- 1 | id; 45 | } 46 | 47 | /** 48 | * Set id. 49 | * 50 | * @param int $id 51 | * @return UserInterface 52 | */ 53 | public function setId($id) 54 | { 55 | $this->id = (int) $id; 56 | return $this; 57 | } 58 | 59 | /** 60 | * Get username. 61 | * 62 | * @return string 63 | */ 64 | public function getUsername() 65 | { 66 | return $this->username; 67 | } 68 | 69 | /** 70 | * Set username. 71 | * 72 | * @param string $username 73 | * @return UserInterface 74 | */ 75 | public function setUsername($username) 76 | { 77 | $this->username = $username; 78 | return $this; 79 | } 80 | 81 | /** 82 | * Get email. 83 | * 84 | * @return string 85 | */ 86 | public function getEmail() 87 | { 88 | return $this->email; 89 | } 90 | 91 | /** 92 | * Set email. 93 | * 94 | * @param string $email 95 | * @return UserInterface 96 | */ 97 | public function setEmail($email) 98 | { 99 | $this->email = $email; 100 | return $this; 101 | } 102 | 103 | /** 104 | * Get displayName. 105 | * 106 | * @return string 107 | */ 108 | public function getDisplayName() 109 | { 110 | return $this->displayName; 111 | } 112 | 113 | /** 114 | * Set displayName. 115 | * 116 | * @param string $displayName 117 | * @return UserInterface 118 | */ 119 | public function setDisplayName($displayName) 120 | { 121 | $this->displayName = $displayName; 122 | return $this; 123 | } 124 | 125 | /** 126 | * Get password. 127 | * 128 | * @return string 129 | */ 130 | public function getPassword() 131 | { 132 | return $this->password; 133 | } 134 | 135 | /** 136 | * Set password. 137 | * 138 | * @param string $password 139 | * @return UserInterface 140 | */ 141 | public function setPassword($password) 142 | { 143 | $this->password = $password; 144 | return $this; 145 | } 146 | 147 | /** 148 | * Get state. 149 | * 150 | * @return int 151 | */ 152 | public function getState() 153 | { 154 | return $this->state; 155 | } 156 | 157 | /** 158 | * Set state. 159 | * 160 | * @param int $state 161 | * @return UserInterface 162 | */ 163 | public function setState($state) 164 | { 165 | $this->state = $state; 166 | return $this; 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /src/ZfcUser/Entity/UserInterface.php: -------------------------------------------------------------------------------- 1 | eventIdentifier)) { 26 | if ((is_string($this->eventIdentifier)) 27 | || (is_array($this->eventIdentifier)) 28 | || ($this->eventIdentifier instanceof Traversable) 29 | ) { 30 | $identifiers = array_unique(array_merge($identifiers, (array) $this->eventIdentifier)); 31 | } elseif (is_object($this->eventIdentifier)) { 32 | $identifiers[] = $this->eventIdentifier; 33 | } 34 | // silently ignore invalid eventIdentifier types 35 | } 36 | $events->setIdentifiers($identifiers); 37 | $this->events = $events; 38 | return $this; 39 | } 40 | /** 41 | * Retrieve the event manager 42 | * 43 | * Lazy-loads an EventManager instance if none registered. 44 | * 45 | * @return EventManagerInterface 46 | */ 47 | public function getEventManager() 48 | { 49 | if (!$this->events instanceof EventManagerInterface) { 50 | $this->setEventManager(new EventManager()); 51 | } 52 | return $this->events; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/ZfcUser/Exception/AuthenticationEventException.php: -------------------------------------------------------------------------------- 1 | setServiceManager($serviceLocator); 16 | 17 | return $db; 18 | } 19 | 20 | /** 21 | * Create service 22 | * 23 | * @param ServiceLocatorInterface $serviceLocator 24 | * @return mixed 25 | */ 26 | public function createService(ServiceLocatorInterface $serviceLocator) 27 | { 28 | return $this->__invoke($serviceLocator, null); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/Authentication/Storage/DbFactory.php: -------------------------------------------------------------------------------- 1 | setServiceManager($serviceLocator); 16 | 17 | return $db; 18 | } 19 | 20 | /** 21 | * Create service 22 | * 23 | * @param ServiceLocatorInterface $serviceLocator 24 | * @return mixed 25 | */ 26 | public function createService(ServiceLocatorInterface $serviceLocator) 27 | { 28 | return $this->__invoke($serviceLocator, null); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/AuthenticationService.php: -------------------------------------------------------------------------------- 1 | get('ZfcUser\Authentication\Storage\Db'), 15 | $serviceLocator->get('ZfcUser\Authentication\Adapter\AdapterChain') 16 | ); 17 | } 18 | 19 | /** 20 | * Create service 21 | * 22 | * @param ServiceLocatorInterface $serviceLocator 23 | * @return mixed 24 | */ 25 | public function createService(ServiceLocatorInterface $serviceLocator) 26 | { 27 | return $this->__invoke($serviceLocator, null); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/Controller/Plugin/ZfcUserAuthentication.php: -------------------------------------------------------------------------------- 1 | get('zfcuser_auth_service'); 15 | $authAdapter = $serviceLocator->get('ZfcUser\Authentication\Adapter\AdapterChain'); 16 | 17 | $controllerPlugin = new Controller\Plugin\ZfcUserAuthentication; 18 | $controllerPlugin->setAuthService($authService); 19 | $controllerPlugin->setAuthAdapter($authAdapter); 20 | 21 | return $controllerPlugin; 22 | } 23 | 24 | /** 25 | * Create service 26 | * 27 | * @param ServiceLocatorInterface $serviceManager 28 | * @return mixed 29 | */ 30 | public function createService(ServiceLocatorInterface $serviceManager) 31 | { 32 | $serviceLocator = $serviceManager->getServiceLocator(); 33 | 34 | return $this->__invoke($serviceLocator, null); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/Controller/RedirectCallbackFactory.php: -------------------------------------------------------------------------------- 1 | get('Router'); 19 | 20 | /* @var Application $application */ 21 | $application = $serviceLocator->get('Application'); 22 | 23 | /* @var ModuleOptions $options */ 24 | $options = $serviceLocator->get('zfcuser_module_options'); 25 | 26 | return new RedirectCallback($application, $router, $options); 27 | } 28 | 29 | /** 30 | * Create service 31 | * 32 | * @param ServiceLocatorInterface $serviceLocator 33 | * @return mixed 34 | */ 35 | public function createService(ServiceLocatorInterface $serviceLocator) 36 | { 37 | return $this->__invoke($serviceLocator, null); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/Controller/UserControllerFactory.php: -------------------------------------------------------------------------------- 1 | get('zfcuser_redirect_callback'); 18 | 19 | /* @var UserController $controller */ 20 | $controller = new UserController($redirectCallback); 21 | $controller->setServiceLocator($serviceManager); 22 | 23 | $controller->setChangeEmailForm($serviceManager->get('zfcuser_change_email_form')); 24 | $controller->setOptions($serviceManager->get('zfcuser_module_options')); 25 | $controller->setChangePasswordForm($serviceManager->get('zfcuser_change_password_form')); 26 | $controller->setLoginForm($serviceManager->get('zfcuser_login_form')); 27 | $controller->setRegisterForm($serviceManager->get('zfcuser_register_form')); 28 | $controller->setUserService($serviceManager->get('zfcuser_user_service')); 29 | 30 | return $controller; 31 | } 32 | 33 | /** 34 | * Create service 35 | * 36 | * @param ServiceLocatorInterface $controllerManager 37 | * @return mixed 38 | */ 39 | public function createService(ServiceLocatorInterface $controllerManager) 40 | { 41 | /* @var ControllerManager $controllerManager*/ 42 | $serviceManager = $controllerManager->getServiceLocator(); 43 | 44 | return $this->__invoke($serviceManager, null); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/Form/ChangeEmail.php: -------------------------------------------------------------------------------- 1 | get('zfcuser_module_options'); 15 | $form = new Form\ChangeEmail(null, $options); 16 | 17 | $form->setInputFilter(new Form\ChangeEmailFilter( 18 | $options, 19 | new Validator\NoRecordExists(array( 20 | 'mapper' => $serviceManager->get('zfcuser_user_mapper'), 21 | 'key' => 'email' 22 | )) 23 | )); 24 | 25 | return $form; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/Form/ChangePassword.php: -------------------------------------------------------------------------------- 1 | get('zfcuser_module_options'); 14 | $form = new Form\ChangePassword(null, $options); 15 | 16 | $form->setInputFilter(new Form\ChangePasswordFilter($options)); 17 | 18 | return $form; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/Form/Login.php: -------------------------------------------------------------------------------- 1 | get('zfcuser_module_options'); 14 | $form = new Form\Login(null, $options); 15 | 16 | $form->setInputFilter(new Form\LoginFilter($options)); 17 | 18 | return $form; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/Form/Register.php: -------------------------------------------------------------------------------- 1 | get('zfcuser_module_options'); 15 | $form = new Form\Register(null, $options); 16 | 17 | //$form->setCaptchaElement($sm->get('zfcuser_captcha_element')); 18 | $form->setHydrator($serviceManager->get('zfcuser_register_form_hydrator')); 19 | $form->setInputFilter(new Form\RegisterFilter( 20 | new Validator\NoRecordExists(array( 21 | 'mapper' => $serviceManager->get('zfcuser_user_mapper'), 22 | 'key' => 'email' 23 | )), 24 | new Validator\NoRecordExists(array( 25 | 'mapper' => $serviceManager->get('zfcuser_user_mapper'), 26 | 'key' => 'username' 27 | )), 28 | $options 29 | )); 30 | 31 | return $form; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/Mapper/User.php: -------------------------------------------------------------------------------- 1 | get('zfcuser_module_options'); 17 | $dbAdapter = $serviceLocator->get('zfcuser_zend_db_adapter'); 18 | 19 | $entityClass = $options->getUserEntityClass(); 20 | $tableName = $options->getTableName(); 21 | 22 | $mapper = new Mapper\User(); 23 | $mapper->setDbAdapter($dbAdapter); 24 | $mapper->setTableName($tableName); 25 | $mapper->setEntityPrototype(new $entityClass); 26 | $mapper->setHydrator(new Mapper\UserHydrator()); 27 | 28 | return $mapper; 29 | } 30 | 31 | /** 32 | * Create service 33 | * 34 | * @param ServiceLocatorInterface $serviceLocator 35 | * @return mixed 36 | */ 37 | public function createService(ServiceLocatorInterface $serviceLocator) 38 | { 39 | return $this->__invoke($serviceLocator, null); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/Options/ModuleOptions.php: -------------------------------------------------------------------------------- 1 | get('Config'); 15 | 16 | return new Options\ModuleOptions(isset($config['zfcuser']) ? $config['zfcuser'] : array()); 17 | } 18 | 19 | /** 20 | * Create service 21 | * 22 | * @param ServiceLocatorInterface $serviceLocator 23 | * @return mixed 24 | */ 25 | public function createService(ServiceLocatorInterface $serviceLocator) 26 | { 27 | return $this->__invoke($serviceLocator, null); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/Service/UserFactory.php: -------------------------------------------------------------------------------- 1 | setServiceManager($serviceLocator); 16 | 17 | return $service; 18 | } 19 | 20 | /** 21 | * Create service 22 | * 23 | * @param ServiceLocatorInterface $serviceLocator 24 | * @return mixed 25 | */ 26 | public function createService(ServiceLocatorInterface $serviceLocator) 27 | { 28 | return $this->__invoke($serviceLocator, null); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/UserHydrator.php: -------------------------------------------------------------------------------- 1 | __invoke($serviceLocator, null); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/View/Helper/ZfcUserDisplayName.php: -------------------------------------------------------------------------------- 1 | setAuthService($container->get('zfcuser_auth_service')); 15 | 16 | return $viewHelper; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/View/Helper/ZfcUserIdentity.php: -------------------------------------------------------------------------------- 1 | setAuthService($container->get('zfcuser_auth_service')); 15 | 16 | return $viewHelper; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ZfcUser/Factory/View/Helper/ZfcUserLoginWidget.php: -------------------------------------------------------------------------------- 1 | setViewTemplate($container->get('zfcuser_module_options')->getUserLoginWidgetViewTemplate()); 15 | $viewHelper->setLoginForm($container->get('zfcuser_login_form')); 16 | 17 | return $viewHelper; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/ZfcUser/Form/Base.php: -------------------------------------------------------------------------------- 1 | add(array( 14 | 'name' => 'username', 15 | 'options' => array( 16 | 'label' => 'Username', 17 | ), 18 | 'attributes' => array( 19 | 'type' => 'text' 20 | ), 21 | )); 22 | 23 | $this->add(array( 24 | 'name' => 'email', 25 | 'options' => array( 26 | 'label' => 'Email', 27 | ), 28 | 'attributes' => array( 29 | 'type' => 'text' 30 | ), 31 | )); 32 | 33 | $this->add(array( 34 | 'name' => 'display_name', 35 | 'options' => array( 36 | 'label' => 'Display Name', 37 | ), 38 | 'attributes' => array( 39 | 'type' => 'text' 40 | ), 41 | )); 42 | 43 | $this->add(array( 44 | 'name' => 'password', 45 | 'type' => 'password', 46 | 'options' => array( 47 | 'label' => 'Password', 48 | ), 49 | 'attributes' => array( 50 | 'type' => 'password' 51 | ), 52 | )); 53 | 54 | $this->add(array( 55 | 'name' => 'passwordVerify', 56 | 'type' => 'password', 57 | 'options' => array( 58 | 'label' => 'Password Verify', 59 | ), 60 | 'attributes' => array( 61 | 'type' => 'password' 62 | ), 63 | )); 64 | 65 | $submitElement = new Element\Button('submit'); 66 | $submitElement 67 | ->setLabel('Submit') 68 | ->setAttributes(array( 69 | 'type' => 'submit', 70 | )); 71 | 72 | $this->add($submitElement, array( 73 | 'priority' => -100, 74 | )); 75 | 76 | $this->add(array( 77 | 'name' => 'userId', 78 | 'type' => 'Zend\Form\Element\Hidden', 79 | 'attributes' => array( 80 | 'type' => 'hidden' 81 | ), 82 | )); 83 | 84 | // @TODO: Fix this... getValidator() is a protected method. 85 | //$csrf = new Element\Csrf('csrf'); 86 | //$csrf->getValidator()->setTimeout($this->getRegistrationOptions()->getUserFormTimeout()); 87 | //$this->add($csrf); 88 | } 89 | 90 | public function init() 91 | { 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/ZfcUser/Form/ChangeEmail.php: -------------------------------------------------------------------------------- 1 | setAuthenticationOptions($options); 17 | 18 | parent::__construct($name); 19 | 20 | $this->add(array( 21 | 'name' => 'identity', 22 | 'options' => array( 23 | 'label' => '', 24 | ), 25 | 'attributes' => array( 26 | 'type' => 'hidden', 27 | ), 28 | )); 29 | 30 | $this->add(array( 31 | 'name' => 'newIdentity', 32 | 'options' => array( 33 | 'label' => 'New Email', 34 | ), 35 | 'attributes' => array( 36 | 'type' => 'text', 37 | ), 38 | )); 39 | 40 | $this->add(array( 41 | 'name' => 'newIdentityVerify', 42 | 'options' => array( 43 | 'label' => 'Verify New Email', 44 | ), 45 | 'attributes' => array( 46 | 'type' => 'text', 47 | ), 48 | )); 49 | 50 | $this->add(array( 51 | 'name' => 'credential', 52 | 'type' => 'password', 53 | 'options' => array( 54 | 'label' => 'Password', 55 | ), 56 | 'attributes' => array( 57 | 'type' => 'password', 58 | ), 59 | )); 60 | 61 | $this->add(array( 62 | 'name' => 'submit', 63 | 'attributes' => array( 64 | 'value' => 'Submit', 65 | 'type' => 'submit' 66 | ), 67 | )); 68 | } 69 | 70 | /** 71 | * Set Authentication-related Options 72 | * 73 | * @param AuthenticationOptionsInterface $authOptions 74 | * @return ChangeEmail 75 | */ 76 | public function setAuthenticationOptions(AuthenticationOptionsInterface $authOptions) 77 | { 78 | $this->authOptions = $authOptions; 79 | 80 | return $this; 81 | } 82 | 83 | /** 84 | * Get Authentication-related Options 85 | * 86 | * @return AuthenticationOptionsInterface 87 | */ 88 | public function getAuthenticationOptions() 89 | { 90 | return $this->authOptions; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/ZfcUser/Form/ChangeEmailFilter.php: -------------------------------------------------------------------------------- 1 | emailValidator = $emailValidator; 15 | 16 | $identityParams = array( 17 | 'name' => 'identity', 18 | 'required' => true, 19 | 'validators' => array() 20 | ); 21 | 22 | $identityFields = $options->getAuthIdentityFields(); 23 | if ($identityFields == array('email')) { 24 | $validators = array('name' => 'EmailAddress'); 25 | array_push($identityParams['validators'], $validators); 26 | } 27 | 28 | $this->add($identityParams); 29 | 30 | $this->add(array( 31 | 'name' => 'newIdentity', 32 | 'required' => true, 33 | 'validators' => array( 34 | array( 35 | 'name' => 'EmailAddress' 36 | ), 37 | $this->emailValidator 38 | ), 39 | )); 40 | 41 | $this->add(array( 42 | 'name' => 'newIdentityVerify', 43 | 'required' => true, 44 | 'validators' => array( 45 | array( 46 | 'name' => 'identical', 47 | 'options' => array( 48 | 'token' => 'newIdentity' 49 | ) 50 | ), 51 | ), 52 | )); 53 | } 54 | 55 | public function getEmailValidator() 56 | { 57 | return $this->emailValidator; 58 | } 59 | 60 | public function setEmailValidator($emailValidator) 61 | { 62 | $this->emailValidator = $emailValidator; 63 | return $this; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/ZfcUser/Form/ChangePassword.php: -------------------------------------------------------------------------------- 1 | setAuthenticationOptions($options); 17 | 18 | parent::__construct($name); 19 | 20 | $this->add(array( 21 | 'name' => 'identity', 22 | 'options' => array( 23 | 'label' => '', 24 | ), 25 | 'attributes' => array( 26 | 'type' => 'hidden' 27 | ), 28 | )); 29 | 30 | $this->add(array( 31 | 'name' => 'credential', 32 | 'type' => 'password', 33 | 'options' => array( 34 | 'label' => 'Current Password', 35 | ), 36 | 'attributes' => array( 37 | 'type' => 'password', 38 | ), 39 | )); 40 | 41 | $this->add(array( 42 | 'name' => 'newCredential', 43 | 'options' => array( 44 | 'label' => 'New Password', 45 | ), 46 | 'attributes' => array( 47 | 'type' => 'password', 48 | ), 49 | )); 50 | 51 | $this->add(array( 52 | 'name' => 'newCredentialVerify', 53 | 'type' => 'password', 54 | 'options' => array( 55 | 'label' => 'Verify New Password', 56 | ), 57 | 'attributes' => array( 58 | 'type' => 'password', 59 | ), 60 | )); 61 | 62 | $this->add(array( 63 | 'name' => 'submit', 64 | 'attributes' => array( 65 | 'value' => 'Submit', 66 | 'type' => 'submit' 67 | ), 68 | )); 69 | } 70 | 71 | /** 72 | * Set Authentication-related Options 73 | * 74 | * @param AuthenticationOptionsInterface $authOptions 75 | * @return ChangePassword 76 | */ 77 | public function setAuthenticationOptions(AuthenticationOptionsInterface $authOptions) 78 | { 79 | $this->authOptions = $authOptions; 80 | 81 | return $this; 82 | } 83 | 84 | /** 85 | * Get Authentication-related Options 86 | * 87 | * @return AuthenticationOptionsInterface 88 | */ 89 | public function getAuthenticationOptions() 90 | { 91 | return $this->authOptions; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/ZfcUser/Form/ChangePasswordFilter.php: -------------------------------------------------------------------------------- 1 | 'identity', 14 | 'required' => true, 15 | 'validators' => array() 16 | ); 17 | 18 | $identityFields = $options->getAuthIdentityFields(); 19 | if ($identityFields == array('email')) { 20 | $validators = array('name' => 'EmailAddress'); 21 | array_push($identityParams['validators'], $validators); 22 | } 23 | 24 | $this->add($identityParams); 25 | 26 | $this->add(array( 27 | 'name' => 'credential', 28 | 'required' => true, 29 | 'validators' => array( 30 | array( 31 | 'name' => 'StringLength', 32 | 'options' => array( 33 | 'min' => 6, 34 | ), 35 | ), 36 | ), 37 | 'filters' => array( 38 | array('name' => 'StringTrim'), 39 | ), 40 | )); 41 | 42 | $this->add(array( 43 | 'name' => 'newCredential', 44 | 'required' => true, 45 | 'validators' => array( 46 | array( 47 | 'name' => 'StringLength', 48 | 'options' => array( 49 | 'min' => 6, 50 | ), 51 | ), 52 | ), 53 | 'filters' => array( 54 | array('name' => 'StringTrim'), 55 | ), 56 | )); 57 | 58 | $this->add(array( 59 | 'name' => 'newCredentialVerify', 60 | 'required' => true, 61 | 'validators' => array( 62 | array( 63 | 'name' => 'StringLength', 64 | 'options' => array( 65 | 'min' => 6, 66 | ), 67 | ), 68 | array( 69 | 'name' => 'identical', 70 | 'options' => array( 71 | 'token' => 'newCredential' 72 | ) 73 | ), 74 | ), 75 | 'filters' => array( 76 | array('name' => 'StringTrim'), 77 | ), 78 | )); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/ZfcUser/Form/Login.php: -------------------------------------------------------------------------------- 1 | setAuthenticationOptions($options); 18 | 19 | parent::__construct($name); 20 | 21 | $this->add(array( 22 | 'name' => 'identity', 23 | 'options' => array( 24 | 'label' => '', 25 | ), 26 | 'attributes' => array( 27 | 'type' => 'text' 28 | ), 29 | )); 30 | 31 | $emailElement = $this->get('identity'); 32 | $label = $emailElement->getLabel('label'); 33 | // @TODO: make translation-friendly 34 | foreach ($this->getAuthenticationOptions()->getAuthIdentityFields() as $mode) { 35 | $label = (!empty($label) ? $label . ' or ' : '') . ucfirst($mode); 36 | } 37 | $emailElement->setLabel($label); 38 | // 39 | $this->add(array( 40 | 'name' => 'credential', 41 | 'type' => 'password', 42 | 'options' => array( 43 | 'label' => 'Password', 44 | ), 45 | 'attributes' => array( 46 | 'type' => 'password', 47 | ), 48 | )); 49 | 50 | // @todo: Fix this 51 | // 1) getValidator() is a protected method 52 | // 2) i don't believe the login form is actually being validated by the login action 53 | // (but keep in mind we don't want to show invalid username vs invalid password or 54 | // anything like that, it should just say "login failed" without any additional info) 55 | //$csrf = new Element\Csrf('csrf'); 56 | //$csrf->getValidator()->setTimeout($options->getLoginFormTimeout()); 57 | //$this->add($csrf); 58 | 59 | $submitElement = new Element\Button('submit'); 60 | $submitElement 61 | ->setLabel('Sign In') 62 | ->setAttributes(array( 63 | 'type' => 'submit', 64 | )); 65 | 66 | $this->add($submitElement, array( 67 | 'priority' => -100, 68 | )); 69 | } 70 | 71 | /** 72 | * Set Authentication-related Options 73 | * 74 | * @param AuthenticationOptionsInterface $authOptions 75 | * @return Login 76 | */ 77 | public function setAuthenticationOptions(AuthenticationOptionsInterface $authOptions) 78 | { 79 | $this->authOptions = $authOptions; 80 | 81 | return $this; 82 | } 83 | 84 | /** 85 | * Get Authentication-related Options 86 | * 87 | * @return AuthenticationOptionsInterface 88 | */ 89 | public function getAuthenticationOptions() 90 | { 91 | return $this->authOptions; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/ZfcUser/Form/LoginFilter.php: -------------------------------------------------------------------------------- 1 | 'identity', 14 | 'required' => true, 15 | 'validators' => array() 16 | ); 17 | 18 | $identityFields = $options->getAuthIdentityFields(); 19 | if ($identityFields == array('email')) { 20 | $validators = array('name' => 'EmailAddress'); 21 | array_push($identityParams['validators'], $validators); 22 | } 23 | 24 | $this->add($identityParams); 25 | 26 | $this->add(array( 27 | 'name' => 'credential', 28 | 'required' => true, 29 | 'validators' => array( 30 | array( 31 | 'name' => 'StringLength', 32 | 'options' => array( 33 | 'min' => 6, 34 | ), 35 | ), 36 | ), 37 | 'filters' => array( 38 | array('name' => 'StringTrim'), 39 | ), 40 | )); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/ZfcUser/Form/ProvidesEventsForm.php: -------------------------------------------------------------------------------- 1 | setRegistrationOptions($options); 24 | 25 | parent::__construct($name); 26 | 27 | if ($this->getRegistrationOptions()->getUseRegistrationFormCaptcha()) { 28 | $this->add(array( 29 | 'name' => 'captcha', 30 | 'type' => 'Zend\Form\Element\Captcha', 31 | 'options' => array( 32 | 'label' => 'Please type the following text', 33 | 'captcha' => $this->getRegistrationOptions()->getFormCaptchaOptions(), 34 | ), 35 | )); 36 | } 37 | 38 | $this->remove('userId'); 39 | if (!$this->getRegistrationOptions()->getEnableUsername()) { 40 | $this->remove('username'); 41 | } 42 | if (!$this->getRegistrationOptions()->getEnableDisplayName()) { 43 | $this->remove('display_name'); 44 | } 45 | if ($this->getRegistrationOptions()->getUseRegistrationFormCaptcha() && $this->captchaElement) { 46 | $this->add($this->captchaElement, array('name'=>'captcha')); 47 | } 48 | $this->get('submit')->setLabel('Register'); 49 | } 50 | 51 | public function setCaptchaElement(Captcha $captchaElement) 52 | { 53 | $this->captchaElement= $captchaElement; 54 | } 55 | 56 | /** 57 | * Set Registration Options 58 | * 59 | * @param RegistrationOptionsInterface $registrationOptions 60 | * @return Register 61 | */ 62 | public function setRegistrationOptions(RegistrationOptionsInterface $registrationOptions) 63 | { 64 | $this->registrationOptions = $registrationOptions; 65 | return $this; 66 | } 67 | 68 | /** 69 | * Get Registration Options 70 | * 71 | * @return RegistrationOptionsInterface 72 | */ 73 | public function getRegistrationOptions() 74 | { 75 | return $this->registrationOptions; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/ZfcUser/Form/RegisterFilter.php: -------------------------------------------------------------------------------- 1 | setOptions($options); 21 | $this->emailValidator = $emailValidator; 22 | $this->usernameValidator = $usernameValidator; 23 | 24 | if ($this->getOptions()->getEnableUsername()) { 25 | $this->add(array( 26 | 'name' => 'username', 27 | 'required' => true, 28 | 'validators' => array( 29 | array( 30 | 'name' => 'StringLength', 31 | 'options' => array( 32 | 'min' => 3, 33 | 'max' => 255, 34 | ), 35 | ), 36 | $this->usernameValidator, 37 | ), 38 | )); 39 | } 40 | 41 | $this->add(array( 42 | 'name' => 'email', 43 | 'required' => true, 44 | 'validators' => array( 45 | array( 46 | 'name' => 'EmailAddress' 47 | ), 48 | $this->emailValidator 49 | ), 50 | )); 51 | 52 | if ($this->getOptions()->getEnableDisplayName()) { 53 | $this->add(array( 54 | 'name' => 'display_name', 55 | 'required' => true, 56 | 'filters' => array(array('name' => 'StringTrim')), 57 | 'validators' => array( 58 | array( 59 | 'name' => 'StringLength', 60 | 'options' => array( 61 | 'min' => 3, 62 | 'max' => 128, 63 | ), 64 | ), 65 | ), 66 | )); 67 | } 68 | 69 | $this->add(array( 70 | 'name' => 'password', 71 | 'required' => true, 72 | 'filters' => array(array('name' => 'StringTrim')), 73 | 'validators' => array( 74 | array( 75 | 'name' => 'StringLength', 76 | 'options' => array( 77 | 'min' => 6, 78 | ), 79 | ), 80 | ), 81 | )); 82 | 83 | $this->add(array( 84 | 'name' => 'passwordVerify', 85 | 'required' => true, 86 | 'filters' => array(array('name' => 'StringTrim')), 87 | 'validators' => array( 88 | array( 89 | 'name' => 'StringLength', 90 | 'options' => array( 91 | 'min' => 6, 92 | ), 93 | ), 94 | array( 95 | 'name' => 'Identical', 96 | 'options' => array( 97 | 'token' => 'password', 98 | ), 99 | ), 100 | ), 101 | )); 102 | } 103 | 104 | public function getEmailValidator() 105 | { 106 | return $this->emailValidator; 107 | } 108 | 109 | public function setEmailValidator($emailValidator) 110 | { 111 | $this->emailValidator = $emailValidator; 112 | return $this; 113 | } 114 | 115 | public function getUsernameValidator() 116 | { 117 | return $this->usernameValidator; 118 | } 119 | 120 | public function setUsernameValidator($usernameValidator) 121 | { 122 | $this->usernameValidator = $usernameValidator; 123 | return $this; 124 | } 125 | 126 | /** 127 | * set options 128 | * 129 | * @param RegistrationOptionsInterface $options 130 | */ 131 | public function setOptions(RegistrationOptionsInterface $options) 132 | { 133 | $this->options = $options; 134 | return $this; 135 | } 136 | 137 | /** 138 | * get options 139 | * 140 | * @return RegistrationOptionsInterface 141 | */ 142 | public function getOptions() 143 | { 144 | return $this->options; 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/ZfcUser/InputFilter/ProvidesEventsInputFilter.php: -------------------------------------------------------------------------------- 1 | getSelect() 15 | ->where(array('email' => $email)); 16 | $entity = $this->select($select)->current(); 17 | 18 | $this->getEventManager()->trigger('find', $this, array('entity' => $entity)); 19 | 20 | return $entity; 21 | } 22 | 23 | public function findByUsername($username) 24 | { 25 | $select = $this->getSelect() 26 | ->where(array('username' => $username)); 27 | $entity = $this->select($select)->current(); 28 | 29 | $this->getEventManager()->trigger('find', $this, array('entity' => $entity)); 30 | 31 | return $entity; 32 | } 33 | 34 | public function findById($id) 35 | { 36 | $select = $this->getSelect() 37 | ->where(array('user_id' => $id)); 38 | $entity = $this->select($select)->current(); 39 | 40 | $this->getEventManager()->trigger('find', $this, array('entity' => $entity)); 41 | 42 | return $entity; 43 | } 44 | 45 | public function getTableName() 46 | { 47 | return $this->tableName; 48 | } 49 | 50 | public function setTableName($tableName) 51 | { 52 | $this->tableName = $tableName; 53 | } 54 | 55 | public function insert(UserEntityInterface $entity, $tableName = null, HydratorInterface $hydrator = null) 56 | { 57 | $result = parent::insert($entity, $tableName, $hydrator); 58 | 59 | $entity->setId($result->getGeneratedValue()); 60 | 61 | return $result; 62 | } 63 | 64 | public function update(UserEntityInterface $entity, $where = null, $tableName = null, HydratorInterface $hydrator = null) 65 | { 66 | if (!$where) { 67 | $where = array('user_id' => $entity->getId()); 68 | } 69 | 70 | return parent::update($entity, $where, $tableName, $hydrator); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/ZfcUser/Mapper/UserHydrator.php: -------------------------------------------------------------------------------- 1 | mapField('id', 'user_id', $data); 27 | } else { 28 | unset($data['id']); 29 | } 30 | 31 | return $data; 32 | } 33 | 34 | /** 35 | * Hydrate $object with the provided $data. 36 | * 37 | * @param array $data 38 | * @param UserEntityInterface $object 39 | * @return UserInterface 40 | * @throws Exception\InvalidArgumentException 41 | */ 42 | public function hydrate(array $data, $object) 43 | { 44 | if (!$object instanceof UserEntityInterface) { 45 | throw new Exception\InvalidArgumentException('$object must be an instance of ZfcUser\Entity\UserInterface'); 46 | } 47 | 48 | $data = $this->mapField('user_id', 'id', $data); 49 | 50 | return parent::hydrate($data, $object); 51 | } 52 | 53 | /** 54 | * @param string $keyFrom 55 | * @param string $keyTo 56 | * @param array $array 57 | * @return array 58 | */ 59 | protected function mapField($keyFrom, $keyTo, array $array) 60 | { 61 | $array[$keyTo] = $array[$keyFrom]; 62 | unset($array[$keyFrom]); 63 | 64 | return $array; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/ZfcUser/Mapper/UserInterface.php: -------------------------------------------------------------------------------- 1 | "No record matching the input was found", 21 | self::ERROR_RECORD_FOUND => "A record matching the input was found", 22 | ); 23 | 24 | /** 25 | * @var UserInterface 26 | */ 27 | protected $mapper; 28 | 29 | /** 30 | * @var string 31 | */ 32 | protected $key; 33 | 34 | /** 35 | * Required options are: 36 | * - key Field to use, 'email' or 'username' 37 | */ 38 | public function __construct(array $options) 39 | { 40 | if (!array_key_exists('key', $options)) { 41 | throw new Exception\InvalidArgumentException('No key provided'); 42 | } 43 | 44 | $this->setKey($options['key']); 45 | 46 | parent::__construct($options); 47 | } 48 | 49 | /** 50 | * getMapper 51 | * 52 | * @return UserInterface 53 | */ 54 | public function getMapper() 55 | { 56 | return $this->mapper; 57 | } 58 | 59 | /** 60 | * setMapper 61 | * 62 | * @param UserInterface $mapper 63 | * @return AbstractRecord 64 | */ 65 | public function setMapper(UserInterface $mapper) 66 | { 67 | $this->mapper = $mapper; 68 | return $this; 69 | } 70 | 71 | /** 72 | * Get key. 73 | * 74 | * @return string 75 | */ 76 | public function getKey() 77 | { 78 | return $this->key; 79 | } 80 | 81 | /** 82 | * Set key. 83 | * 84 | * @param string $key 85 | */ 86 | public function setKey($key) 87 | { 88 | $this->key = $key; 89 | return $this; 90 | } 91 | 92 | /** 93 | * Grab the user from the mapper 94 | * 95 | * @param string $value 96 | * @return mixed 97 | */ 98 | protected function query($value) 99 | { 100 | $result = false; 101 | 102 | switch ($this->getKey()) { 103 | case 'email': 104 | $result = $this->getMapper()->findByEmail($value); 105 | break; 106 | 107 | case 'username': 108 | $result = $this->getMapper()->findByUsername($value); 109 | break; 110 | 111 | default: 112 | throw new \Exception('Invalid key used in ZfcUser validator'); 113 | break; 114 | } 115 | 116 | return $result; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/ZfcUser/Validator/Exception/ExceptionInterface.php: -------------------------------------------------------------------------------- 1 | setValue($value); 11 | 12 | $result = $this->query($value); 13 | if ($result) { 14 | $valid = false; 15 | $this->error(self::ERROR_RECORD_FOUND); 16 | } 17 | 18 | return $valid; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ZfcUser/Validator/RecordExists.php: -------------------------------------------------------------------------------- 1 | setValue($value); 11 | 12 | $result = $this->query($value); 13 | if (!$result) { 14 | $valid = false; 15 | $this->error(self::ERROR_NO_RECORD_FOUND); 16 | } 17 | 18 | return $valid; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ZfcUser/View/Helper/ZfcUserDisplayName.php: -------------------------------------------------------------------------------- 1 | getAuthService()->hasIdentity()) { 28 | $user = $this->getAuthService()->getIdentity(); 29 | if (!$user instanceof User) { 30 | throw new \ZfcUser\Exception\DomainException( 31 | '$user is not an instance of User', 32 | 500 33 | ); 34 | } 35 | } else { 36 | return false; 37 | } 38 | } 39 | 40 | $displayName = $user->getDisplayName(); 41 | if (null === $displayName) { 42 | $displayName = $user->getUsername(); 43 | } 44 | // User will always have an email, so we do not have to throw error 45 | if (null === $displayName) { 46 | $displayName = $user->getEmail(); 47 | $displayName = substr($displayName, 0, strpos($displayName, '@')); 48 | } 49 | 50 | return $displayName; 51 | } 52 | 53 | /** 54 | * Get authService. 55 | * 56 | * @return AuthenticationService 57 | */ 58 | public function getAuthService() 59 | { 60 | return $this->authService; 61 | } 62 | 63 | /** 64 | * Set authService. 65 | * 66 | * @param AuthenticationService $authService 67 | * @return \ZfcUser\View\Helper\ZfcUserDisplayName 68 | */ 69 | public function setAuthService(AuthenticationService $authService) 70 | { 71 | $this->authService = $authService; 72 | return $this; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/ZfcUser/View/Helper/ZfcUserIdentity.php: -------------------------------------------------------------------------------- 1 | getAuthService()->hasIdentity()) { 24 | return $this->getAuthService()->getIdentity(); 25 | } else { 26 | return false; 27 | } 28 | } 29 | 30 | /** 31 | * Get authService. 32 | * 33 | * @return AuthenticationService 34 | */ 35 | public function getAuthService() 36 | { 37 | return $this->authService; 38 | } 39 | 40 | /** 41 | * Set authService. 42 | * 43 | * @param AuthenticationService $authService 44 | * @return \ZfcUser\View\Helper\ZfcUserIdentity 45 | */ 46 | public function setAuthService(AuthenticationService $authService) 47 | { 48 | $this->authService = $authService; 49 | return $this; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/ZfcUser/View/Helper/ZfcUserLoginWidget.php: -------------------------------------------------------------------------------- 1 | $this->getLoginForm(), 43 | 'redirect' => $redirect, 44 | )); 45 | $vm->setTemplate($this->viewTemplate); 46 | if ($render) { 47 | return $this->getView()->render($vm); 48 | } else { 49 | return $vm; 50 | } 51 | } 52 | 53 | /** 54 | * Retrieve Login Form Object 55 | * @return LoginForm 56 | */ 57 | public function getLoginForm() 58 | { 59 | return $this->loginForm; 60 | } 61 | 62 | /** 63 | * Inject Login Form Object 64 | * @param LoginForm $loginForm 65 | * @return ZfcUserLoginWidget 66 | */ 67 | public function setLoginForm(LoginForm $loginForm) 68 | { 69 | $this->loginForm = $loginForm; 70 | return $this; 71 | } 72 | 73 | /** 74 | * @param string $viewTemplate 75 | * @return ZfcUserLoginWidget 76 | */ 77 | public function setViewTemplate($viewTemplate) 78 | { 79 | $this->viewTemplate = $viewTemplate; 80 | return $this; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/ZfcUser/language/cs_CZ.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZF-Commons/ZfcUser/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/language/cs_CZ.mo -------------------------------------------------------------------------------- /src/ZfcUser/language/cs_CZ.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: ZfcUser\n" 4 | "POT-Creation-Date: 2015-02-09 15:35+0100\n" 5 | "PO-Revision-Date: 2015-02-09 15:36+0100\n" 6 | "Last-Translator: Martin Vagovszký \n" 7 | "Language-Team: ZF Contibutors \n" 8 | "Language: cs_CZ\n" 9 | "MIME-Version: 1.0\n" 10 | "Content-Type: text/plain; charset=UTF-8\n" 11 | "Content-Transfer-Encoding: 8bit\n" 12 | "X-Generator: Poedit 1.5.7\n" 13 | "X-Poedit-KeywordsList: translate\n" 14 | "X-Poedit-Basepath: ../../../\n" 15 | "X-Poedit-SourceCharset: UTF-8\n" 16 | "X-Poedit-SearchPath-0: .\n" 17 | 18 | #: src/ZfcUser/language/msgIds.php:6 19 | msgid "Username" 20 | msgstr "Uživatelské jméno" 21 | 22 | #: src/ZfcUser/language/msgIds.php:7 23 | msgid "Email" 24 | msgstr "Email" 25 | 26 | #: src/ZfcUser/language/msgIds.php:8 27 | msgid "New Email" 28 | msgstr "Nový email" 29 | 30 | #: src/ZfcUser/language/msgIds.php:9 31 | msgid "Verify New Email" 32 | msgstr "Ověření nového emailu" 33 | 34 | #: src/ZfcUser/language/msgIds.php:10 35 | msgid "Display Name" 36 | msgstr "Zobrazované jméno" 37 | 38 | #: src/ZfcUser/language/msgIds.php:11 39 | msgid "Password" 40 | msgstr "Heslo" 41 | 42 | #: src/ZfcUser/language/msgIds.php:12 43 | msgid "Password Verify" 44 | msgstr "Ověření hesla" 45 | 46 | #: src/ZfcUser/language/msgIds.php:13 47 | msgid "Current Password" 48 | msgstr "Současné heslo" 49 | 50 | #: src/ZfcUser/language/msgIds.php:14 51 | msgid "Verify New Password" 52 | msgstr "Ověření nového hesla" 53 | 54 | #: src/ZfcUser/language/msgIds.php:15 55 | msgid "New Password" 56 | msgstr "Nové heslo" 57 | 58 | #: src/ZfcUser/language/msgIds.php:16 59 | msgid "Please type the following text" 60 | msgstr "Prosím opište následující text" 61 | 62 | #: src/ZfcUser/language/msgIds.php:17 63 | msgid "Submit" 64 | msgstr "Odeslat" 65 | 66 | #: src/ZfcUser/language/msgIds.php:18 view/zfc-user/user/login.phtml:1 67 | msgid "Sign In" 68 | msgstr "Přihlášení" 69 | 70 | #: src/ZfcUser/language/msgIds.php:19 view/zfc-user/user/register.phtml:1 71 | msgid "Register" 72 | msgstr "Registrace" 73 | 74 | #: src/ZfcUser/language/msgIds.php:20 75 | msgid "No record matching the input was found" 76 | msgstr "Nenalezen žádný záznam odpovídající danému zadání" 77 | 78 | #: src/ZfcUser/language/msgIds.php:21 79 | msgid "A record matching the input was found" 80 | msgstr "Byl nalezen záznam odpovídající zadání" 81 | 82 | #: src/ZfcUser/language/msgIds.php:22 83 | msgid "Authentication failed. Please try again." 84 | msgstr "Autentizace selhala. Prosím zkuste to znovu." 85 | 86 | #: view/zfc-user/user/changeemail.phtml:1 87 | #, php-format 88 | msgid "Change Email for %s" 89 | msgstr "Změna emailu pro %s" 90 | 91 | #: view/zfc-user/user/changeemail.phtml:3 92 | msgid "Email address changed successfully." 93 | msgstr "Emailová adresa úspěšně změněna" 94 | 95 | #: view/zfc-user/user/changeemail.phtml:5 96 | msgid "Unable to update your email address. Please try again." 97 | msgstr "Není možné změnit Vaši emailovou adresu. Zkuste to prosím znovu." 98 | 99 | #: view/zfc-user/user/changepassword.phtml:1 100 | #, php-format 101 | msgid "Change Password for %s" 102 | msgstr "Změna hesla pro %s" 103 | 104 | #: view/zfc-user/user/changepassword.phtml:3 105 | msgid "Password changed successfully." 106 | msgstr "Heslo úspěšně upraveno." 107 | 108 | #: view/zfc-user/user/changepassword.phtml:5 109 | msgid "Unable to update your password. Please try again." 110 | msgstr "Není možné upravit Vaše heslo. Zkuste to prosím později." 111 | 112 | #: view/zfc-user/user/index.phtml:2 113 | msgid "Hello" 114 | msgstr "Dobrý den" 115 | 116 | #: view/zfc-user/user/index.phtml:3 117 | msgid "Sign Out" 118 | msgstr "Odhlášení" 119 | 120 | #: view/zfc-user/user/login.phtml:31 121 | msgid "Not registered?" 122 | msgstr "Nejste registrován/a?" 123 | 124 | #: view/zfc-user/user/login.phtml:31 125 | msgid "Sign up!" 126 | msgstr "Zaregistrujte se!" 127 | -------------------------------------------------------------------------------- /src/ZfcUser/language/de_DE.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZF-Commons/ZfcUser/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/language/de_DE.mo -------------------------------------------------------------------------------- /src/ZfcUser/language/de_DE.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: ZfcUser\n" 4 | "Report-Msgid-Bugs-To: zf-devteam@zend.com\n" 5 | "POT-Creation-Date: 2013-11-08 00:38+0100\n" 6 | "PO-Revision-Date: 2014-02-27 13:36+0100\n" 7 | "Last-Translator: Thomas Szteliga \n" 8 | "Language-Team: ZF Contibutors \n" 9 | "Language: de_DE\n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | 14 | #: src/ZfcUser/language/msgIds.php:6 15 | msgid "Username" 16 | msgstr "Benutzername" 17 | 18 | #: src/ZfcUser/language/msgIds.php:7 19 | msgid "Email" 20 | msgstr "E-Mail" 21 | 22 | #: src/ZfcUser/language/msgIds.php:8 23 | msgid "New Email" 24 | msgstr "Neue E-Mail" 25 | 26 | #: src/ZfcUser/language/msgIds.php:9 27 | msgid "Verify New Email" 28 | msgstr "E-Mail wiederholen" 29 | 30 | #: src/ZfcUser/language/msgIds.php:10 31 | msgid "Display Name" 32 | msgstr "Anzeigename" 33 | 34 | #: src/ZfcUser/language/msgIds.php:11 35 | msgid "Password" 36 | msgstr "Passwort" 37 | 38 | #: src/ZfcUser/language/msgIds.php:12 39 | msgid "Password Verify" 40 | msgstr "Passwort wiederholen" 41 | 42 | #: src/ZfcUser/language/msgIds.php:13 43 | msgid "Current Password" 44 | msgstr "Aktuelles Passwort" 45 | 46 | #: src/ZfcUser/language/msgIds.php:14 47 | msgid "Verify New Password" 48 | msgstr "Neues Passwort wiederholen" 49 | 50 | #: src/ZfcUser/language/msgIds.php:15 51 | msgid "New Password" 52 | msgstr "Neues Passwort" 53 | 54 | #: src/ZfcUser/language/msgIds.php:16 55 | msgid "Please type the following text" 56 | msgstr "Geben Sie bitte den folgenden Text ein" 57 | 58 | #: src/ZfcUser/language/msgIds.php:17 59 | msgid "Submit" 60 | msgstr "Senden" 61 | 62 | #: src/ZfcUser/language/msgIds.php:18 view/zfc-user/user/login.phtml:1 63 | msgid "Sign In" 64 | msgstr "Anmelden" 65 | 66 | #: src/ZfcUser/language/msgIds.php:19 view/zfc-user/user/register.phtml:1 67 | msgid "Register" 68 | msgstr "Registrieren" 69 | 70 | #: src/ZfcUser/language/msgIds.php:20 71 | msgid "No record matching the input was found" 72 | msgstr "Es wurde kein passender Eintrag gefunden" 73 | 74 | #: src/ZfcUser/language/msgIds.php:21 75 | msgid "A record matching the input was found" 76 | msgstr "Zugang existiert bereits." 77 | 78 | #: src/ZfcUser/language/msgIds.php:22 79 | msgid "Authentication failed. Please try again." 80 | msgstr "" 81 | "Authentifizierung fehlgeschlagen. " 82 | "Bitte versuchen Sie es erneut." 83 | 84 | #: view/zfc-user/user/login.phtml:31 85 | msgid "Not registered?" 86 | msgstr "Noch kein Zugang?" 87 | 88 | #: view/zfc-user/user/login.phtml:31 89 | msgid "Sign up!" 90 | msgstr "Jetzt registrieren!" 91 | 92 | #: view/zfc-user/user/changeemail.phtml:1 93 | #, php-format 94 | msgid "Change Email for %s" 95 | msgstr "E-mail ändern für %s" 96 | 97 | #: view/zfc-user/user/changeemail.phtml:3 98 | msgid "Email address changed successfully." 99 | msgstr "Ihre E-Mail wurde erflogreich aktualisiert." 100 | 101 | #: view/zfc-user/user/changeemail.phtml:5 102 | msgid "Unable to update your email address. Please try again." 103 | msgstr "" 104 | "Ihre E-Mail konnte nicht erflogreich aktualisiert werden. " 105 | "Bitte versuchen Sie es erneut." 106 | 107 | #: view/zfc-user/user/changepassword.phtml:1 108 | #, php-format 109 | msgid "Change Password for %s" 110 | msgstr "Passwort ändern für %s" 111 | 112 | #: view/zfc-user/user/changepassword.phtml:3 113 | msgid "Password changed successfully." 114 | msgstr "Ihr Passwort wurde erfolgreich aktualisiert." 115 | 116 | #: view/zfc-user/user/changepassword.phtml:5 117 | msgid "Unable to update your password. Please try again." 118 | msgstr "" 119 | "Ihr Passwort konnte nicht erfolgreich aktualisiert werden. " 120 | "Bitte versuchen Sie es erneut." 121 | 122 | #: view/zfc-user/user/index.phtml:2 123 | msgid "Hello" 124 | msgstr "Hallo" 125 | 126 | #: view/zfc-user/user/index.phtml:3 127 | msgid "Sign Out" 128 | msgstr "Abmelden" 129 | -------------------------------------------------------------------------------- /src/ZfcUser/language/es_ES.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZF-Commons/ZfcUser/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/language/es_ES.mo -------------------------------------------------------------------------------- /src/ZfcUser/language/es_ES.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: ZfcUser\n" 4 | "Report-Msgid-Bugs-To: zf-devteam@zend.com\n" 5 | "POT-Creation-Date: 2013-07-22 12:24+0300\n" 6 | "PO-Revision-Date: 2016-05-25 18:13-0300\n" 7 | "Last-Translator: Matias Iglesias \n" 8 | "Language-Team: Meridiem IT Outsourcing \n" 10 | "Language: es_ES\n" 11 | "MIME-Version: 1.0\n" 12 | "Content-Type: text/plain; charset=UTF-8\n" 13 | "Content-Transfer-Encoding: 8bit\n" 14 | "X-Generator: Poedit 1.8.7\n" 15 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 16 | 17 | #: src/ZfcUser/language/msgIds.php:6 18 | msgid "Username" 19 | msgstr "Nombre de usuario" 20 | 21 | #: src/ZfcUser/language/msgIds.php:7 22 | msgid "Email" 23 | msgstr "Correo electrónico" 24 | 25 | #: src/ZfcUser/language/msgIds.php:8 26 | msgid "New Email" 27 | msgstr "Nuevo correo electrónico" 28 | 29 | #: src/ZfcUser/language/msgIds.php:9 30 | msgid "Verify New Email" 31 | msgstr "Confirmar correo electrónico" 32 | 33 | #: src/ZfcUser/language/msgIds.php:10 34 | msgid "Display Name" 35 | msgstr "Nombre a mostrar" 36 | 37 | #: src/ZfcUser/language/msgIds.php:11 38 | msgid "Password" 39 | msgstr "Contraseña" 40 | 41 | #: src/ZfcUser/language/msgIds.php:12 42 | msgid "Password Verify" 43 | msgstr "Confirmar Contraseña" 44 | 45 | #: src/ZfcUser/language/msgIds.php:13 46 | msgid "Current Password" 47 | msgstr "Contraseña actual" 48 | 49 | #: src/ZfcUser/language/msgIds.php:14 50 | msgid "Verify New Password" 51 | msgstr "Confirmar nueva contraseña" 52 | 53 | #: src/ZfcUser/language/msgIds.php:15 54 | msgid "New Password" 55 | msgstr "Nueva contraseña" 56 | 57 | #: src/ZfcUser/language/msgIds.php:16 58 | msgid "Please type the following text" 59 | msgstr "Por favor, ingrese el siguiente texto" 60 | 61 | #: src/ZfcUser/language/msgIds.php:17 62 | msgid "Submit" 63 | msgstr "Enviar" 64 | 65 | #: src/ZfcUser/language/msgIds.php:18 view/zfc-user/user/login.phtml:1 66 | msgid "Sign In" 67 | msgstr "Iniciar sesión" 68 | 69 | #: src/ZfcUser/language/msgIds.php:19 view/zfc-user/user/register.phtml:1 70 | msgid "Register" 71 | msgstr "Registrarse" 72 | 73 | #: src/ZfcUser/language/msgIds.php:20 74 | msgid "No record matching the input was found" 75 | msgstr "No se encontraron registros coincidentes" 76 | 77 | #: src/ZfcUser/language/msgIds.php:21 78 | msgid "A record matching the input was found" 79 | msgstr "Se encontró un registro coincidente" 80 | 81 | #: src/ZfcUser/language/msgIds.php:22 82 | msgid "Authentication failed. Please try again." 83 | msgstr "Autenticación fallida. Por favor, intente nuevamente." 84 | 85 | #: view/zfc-user/user/login.phtml:31 86 | msgid "Not registered?" 87 | msgstr "Aún no se ha registrado?" 88 | 89 | #: view/zfc-user/user/login.phtml:31 90 | msgid "Sign up!" 91 | msgstr "Regístrese!" 92 | 93 | #: view/zfc-user/user/changeemail.phtml:1 94 | #, php-format 95 | msgid "Change Email for %s" 96 | msgstr "Cambiar correo electrónico por %s" 97 | 98 | #: view/zfc-user/user/changeemail.phtml:3 99 | msgid "Email address changed successfully." 100 | msgstr "" 101 | "La dirección de correo electrónico ha sido cambiada correctamente." 102 | 103 | #: view/zfc-user/user/changeemail.phtml:5 104 | msgid "Unable to update your email address. Please try again." 105 | msgstr "" 106 | "No se pudo actualizar su dirección de correo electrónico. Por favor, " 107 | "intente nuevamente." 108 | 109 | #: view/zfc-user/user/changepassword.phtml:1 110 | #, php-format 111 | msgid "Change Password for %s" 112 | msgstr "Cambiar contraseña por %s" 113 | 114 | #: view/zfc-user/user/changepassword.phtml:3 115 | msgid "Password changed successfully." 116 | msgstr "La contraseña ha sido actualizada correctamente." 117 | 118 | #: view/zfc-user/user/changepassword.phtml:5 119 | msgid "Unable to update your password. Please try again." 120 | msgstr "" 121 | "No se pudo actualizar su contraseña. Por favor, intente nuevamente." 122 | 123 | #: view/zfc-user/user/index.phtml:2 124 | msgid "Hello" 125 | msgstr "Hola" 126 | 127 | #: view/zfc-user/user/index.phtml:3 128 | msgid "Sign Out" 129 | msgstr "Cerrar sesión" 130 | -------------------------------------------------------------------------------- /src/ZfcUser/language/fr_FR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZF-Commons/ZfcUser/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/language/fr_FR.mo -------------------------------------------------------------------------------- /src/ZfcUser/language/fr_FR.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: ZfcUser\n" 4 | "Report-Msgid-Bugs-To: \n" 5 | "POT-Creation-Date: 2013-02-26 13:38+0100\n" 6 | "PO-Revision-Date: 2013-02-26 13:41+0100\n" 7 | "Last-Translator: Belair \n" 8 | "Language-Team: ZF Contibutors \n" 9 | "Language: fr_FR\n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | "X-Poedit-KeywordsList: translate\n" 14 | "X-Poedit-Basepath: /var/www/ZfcUser\n" 15 | "X-Generator: Poedit 1.5.4\n" 16 | "X-Poedit-SearchPath-0: .\n" 17 | 18 | #: src/ZfcUser/language/msgIds.php:6 19 | msgid "Username" 20 | msgstr "Nom d'utilisateur" 21 | 22 | #: src/ZfcUser/language/msgIds.php:7 23 | msgid "Email" 24 | msgstr "Email" 25 | 26 | #: src/ZfcUser/language/msgIds.php:8 27 | msgid "New Email" 28 | msgstr "Nouvel Email" 29 | 30 | #: src/ZfcUser/language/msgIds.php:9 31 | msgid "Verify New Email" 32 | msgstr "Nouvel Émail (vérification)" 33 | 34 | #: src/ZfcUser/language/msgIds.php:10 35 | msgid "Display Name" 36 | msgstr "Nom à afficher" 37 | 38 | #: src/ZfcUser/language/msgIds.php:11 39 | msgid "Password" 40 | msgstr "Mot de passe" 41 | 42 | #: src/ZfcUser/language/msgIds.php:12 43 | msgid "Password Verify" 44 | msgstr "Mot de passe (vérification)" 45 | 46 | #: src/ZfcUser/language/msgIds.php:13 47 | msgid "Current Password" 48 | msgstr "Mot de passe actuel" 49 | 50 | #: src/ZfcUser/language/msgIds.php:14 51 | msgid "Verify New Password" 52 | msgstr "Nouveau mot de passe (vérification)" 53 | 54 | #: src/ZfcUser/language/msgIds.php:15 55 | msgid "New Password" 56 | msgstr "Nouveau mot de passe" 57 | 58 | #: src/ZfcUser/language/msgIds.php:16 59 | msgid "Please type the following text" 60 | msgstr "Merci de saisir le texte suivant" 61 | 62 | #: src/ZfcUser/language/msgIds.php:17 63 | msgid "Submit" 64 | msgstr "Valider" 65 | 66 | #: src/ZfcUser/language/msgIds.php:18 view/zfc-user/user/login.phtml:1 67 | msgid "Sign In" 68 | msgstr "Se connecter" 69 | 70 | #: src/ZfcUser/language/msgIds.php:19 view/zfc-user/user/register.phtml:1 71 | msgid "Register" 72 | msgstr "Créer un compte" 73 | 74 | #: src/ZfcUser/language/msgIds.php:20 75 | msgid "No record matching the input was found" 76 | msgstr "Aucun enregistrement n'a été trouvé avec cette entrée" 77 | 78 | #: src/ZfcUser/language/msgIds.php:21 79 | msgid "A record matching the input was found" 80 | msgstr "Un enregistrement a été trouvé avec cette entrée" 81 | 82 | #: src/ZfcUser/language/msgIds.php:22 83 | msgid "Authentication failed. Please try again." 84 | msgstr "Authentification échouée. Merci de réessayer." 85 | 86 | #: view/zfc-user/user/login.phtml:31 87 | msgid "Not registered?" 88 | msgstr "Pas encore enregistré?" 89 | 90 | #: view/zfc-user/user/login.phtml:31 91 | msgid "Sign up!" 92 | msgstr "Créez un compte!" 93 | 94 | #: view/zfc-user/user/changeemail.phtml:1 95 | #, php-format 96 | msgid "Change Email for %s" 97 | msgstr "Changement de l'émail pour %s" 98 | 99 | #: view/zfc-user/user/changeemail.phtml:3 100 | msgid "Email address changed successfully." 101 | msgstr "L'émail a été modifié" 102 | 103 | #: view/zfc-user/user/changeemail.phtml:5 104 | msgid "Unable to update your email address. Please try again." 105 | msgstr "" 106 | "Impossible de mettre jour votre adresse mail. Merci de réessayer " 107 | "ultérieurement." 108 | 109 | #: view/zfc-user/user/changepassword.phtml:1 110 | #, php-format 111 | msgid "Change Password for %s" 112 | msgstr "Changement du mot de passe pour %s" 113 | 114 | #: view/zfc-user/user/changepassword.phtml:3 115 | msgid "Password changed successfully." 116 | msgstr "Le mot de passe a été modifié avec succès." 117 | 118 | #: view/zfc-user/user/changepassword.phtml:5 119 | msgid "Unable to update your password. Please try again." 120 | msgstr "" 121 | "Impossible de mettre à jour votre mot de passe. Merci de réessayer " 122 | "ultérieurement" 123 | 124 | #: view/zfc-user/user/index.phtml:2 125 | msgid "Hello" 126 | msgstr "Bonjour" 127 | 128 | #: view/zfc-user/user/index.phtml:3 129 | msgid "Sign Out" 130 | msgstr "Se déconnecter" 131 | -------------------------------------------------------------------------------- /src/ZfcUser/language/ja_JP.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZF-Commons/ZfcUser/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/language/ja_JP.mo -------------------------------------------------------------------------------- /src/ZfcUser/language/ja_JP.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: ZfcUser\n" 4 | "Report-Msgid-Bugs-To: \n" 5 | "POT-Creation-Date: 2013-02-26 13:38+0100\n" 6 | "PO-Revision-Date: 2013-11-11 01:19+0900\n" 7 | "Last-Translator: sasezaki \n" 8 | "Language-Team: ZF Contibutors \n" 9 | "Language: ja_JP\n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | "X-Poedit-KeywordsList: translate\n" 14 | "X-Poedit-Basepath: /var/www/ZfcUser\n" 15 | "X-Generator: Poedit 1.5.4\n" 16 | "X-Poedit-SearchPath-0: .\n" 17 | 18 | #: src/ZfcUser/language/msgIds.php:6 19 | msgid "Username" 20 | msgstr "ユーザー名" 21 | 22 | #: src/ZfcUser/language/msgIds.php:7 23 | msgid "Email" 24 | msgstr "メールアドレス" 25 | 26 | #: src/ZfcUser/language/msgIds.php:8 27 | msgid "New Email" 28 | msgstr "新しいメールアドレス" 29 | 30 | #: src/ZfcUser/language/msgIds.php:9 31 | msgid "Verify New Email" 32 | msgstr "新しいメールアドレス (確認)" 33 | 34 | #: src/ZfcUser/language/msgIds.php:10 35 | msgid "Display Name" 36 | msgstr "表示する名前" 37 | 38 | #: src/ZfcUser/language/msgIds.php:11 39 | msgid "Password" 40 | msgstr "パスワード" 41 | 42 | #: src/ZfcUser/language/msgIds.php:12 43 | msgid "Password Verify" 44 | msgstr "パスワード (確認用)" 45 | 46 | #: src/ZfcUser/language/msgIds.php:13 47 | msgid "Current Password" 48 | msgstr "現在のパスワード" 49 | 50 | #: src/ZfcUser/language/msgIds.php:14 51 | msgid "Verify New Password" 52 | msgstr "新しいパスワード (確認用)" 53 | 54 | #: src/ZfcUser/language/msgIds.php:15 55 | msgid "New Password" 56 | msgstr "新しいパスワード" 57 | 58 | #: src/ZfcUser/language/msgIds.php:16 59 | msgid "Please type the following text" 60 | msgstr "次の文章を入力してください" 61 | 62 | #: src/ZfcUser/language/msgIds.php:17 63 | msgid "Submit" 64 | msgstr "送信" 65 | 66 | #: src/ZfcUser/language/msgIds.php:18 67 | #: view/zfc-user/user/login.phtml:1 68 | msgid "Sign In" 69 | msgstr "ログイン" 70 | 71 | #: src/ZfcUser/language/msgIds.php:19 72 | #: view/zfc-user/user/register.phtml:1 73 | msgid "Register" 74 | msgstr "登録する" 75 | 76 | #: src/ZfcUser/language/msgIds.php:20 77 | msgid "No record matching the input was found" 78 | msgstr "入力にマッチしたレコードが見つかりませんでした" 79 | 80 | #: src/ZfcUser/language/msgIds.php:21 81 | msgid "A record matching the input was found" 82 | msgstr "入力にマッチしたレコードが見つかりました" 83 | 84 | #: src/ZfcUser/language/msgIds.php:22 85 | msgid "Authentication failed. Please try again." 86 | msgstr "認証に失敗しました。再度お試しください。" 87 | 88 | #: view/zfc-user/user/login.phtml:31 89 | msgid "Not registered?" 90 | msgstr "登録は済んでいますか?" 91 | 92 | #: view/zfc-user/user/login.phtml:31 93 | msgid "Sign up!" 94 | msgstr "ユーザー登録!" 95 | 96 | #: view/zfc-user/user/changeemail.phtml:1 97 | #, php-format 98 | msgid "Change Email for %s" 99 | msgstr "%s のメールアドレスを変更します" 100 | 101 | #: view/zfc-user/user/changeemail.phtml:3 102 | msgid "Email address changed successfully." 103 | msgstr "メールアドレスの変更に成功しました。" 104 | 105 | #: view/zfc-user/user/changeemail.phtml:5 106 | msgid "Unable to update your email address. Please try again." 107 | msgstr "メールアドレスを更新できません。再度お試しください。" 108 | 109 | #: view/zfc-user/user/changepassword.phtml:1 110 | #, php-format 111 | msgid "Change Password for %s" 112 | msgstr "%s のパスワードを変更します" 113 | 114 | #: view/zfc-user/user/changepassword.phtml:3 115 | msgid "Password changed successfully." 116 | msgstr "パスワードの変更に成功しました。" 117 | 118 | #: view/zfc-user/user/changepassword.phtml:5 119 | msgid "Unable to update your password. Please try again." 120 | msgstr "パスワードを更新できません。再度お試しください。" 121 | 122 | #: view/zfc-user/user/index.phtml:2 123 | msgid "Hello" 124 | msgstr "こんにちは" 125 | 126 | #: view/zfc-user/user/index.phtml:3 127 | msgid "Sign Out" 128 | msgstr "ログアウト" 129 | 130 | -------------------------------------------------------------------------------- /src/ZfcUser/language/msgIds.php: -------------------------------------------------------------------------------- 1 | \n" 8 | "Language-Team: ZF Contibutors \n" 9 | "MIME-Version: 1.0\n" 10 | "Content-Type: text/plain; charset=UTF-8\n" 11 | "Content-Transfer-Encoding: 8bit\n" 12 | "X-Generator: Poedit 1.6.4\n" 13 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 14 | "Language: nl_NL\n" 15 | 16 | #: src/ZfcUser/language/msgIds.php:6 17 | msgid "Username" 18 | msgstr "Gebruikersnaam" 19 | 20 | #: src/ZfcUser/language/msgIds.php:7 21 | msgid "Email" 22 | msgstr "E-mail adres" 23 | 24 | #: src/ZfcUser/language/msgIds.php:8 25 | msgid "New Email" 26 | msgstr "Nieuw e-mail adres" 27 | 28 | #: src/ZfcUser/language/msgIds.php:9 29 | msgid "Verify New Email" 30 | msgstr "Nieuw e-mail adres verificatie" 31 | 32 | #: src/ZfcUser/language/msgIds.php:10 33 | msgid "Display Name" 34 | msgstr "Bijnaam" 35 | 36 | #: src/ZfcUser/language/msgIds.php:11 37 | msgid "Password" 38 | msgstr "Wachtwoord" 39 | 40 | #: src/ZfcUser/language/msgIds.php:12 41 | msgid "Password Verify" 42 | msgstr "Wachtwoord verificatie" 43 | 44 | #: src/ZfcUser/language/msgIds.php:13 45 | msgid "Current Password" 46 | msgstr "Huidig wachtwoord" 47 | 48 | #: src/ZfcUser/language/msgIds.php:14 49 | msgid "Verify New Password" 50 | msgstr "Nieuw wachtwoord verificatie" 51 | 52 | #: src/ZfcUser/language/msgIds.php:15 53 | msgid "New Password" 54 | msgstr "Nieuw wachtwoord" 55 | 56 | #: src/ZfcUser/language/msgIds.php:16 57 | msgid "Please type the following text" 58 | msgstr "Type de volgende tekst" 59 | 60 | #: src/ZfcUser/language/msgIds.php:17 61 | msgid "Submit" 62 | msgstr "Verzend" 63 | 64 | #: src/ZfcUser/language/msgIds.php:18 view/zfc-user/user/login.phtml:1 65 | msgid "Sign In" 66 | msgstr "Aanmelden" 67 | 68 | #: src/ZfcUser/language/msgIds.php:19 view/zfc-user/user/register.phtml:1 69 | msgid "Register" 70 | msgstr "Registreer" 71 | 72 | #: src/ZfcUser/language/msgIds.php:20 73 | msgid "No record matching the input was found" 74 | msgstr "Er zijn geen gegevens gevonden die met de invoer overeenkomen" 75 | 76 | #: src/ZfcUser/language/msgIds.php:21 77 | msgid "A record matching the input was found" 78 | msgstr "Er zijn al gegevens die met de invoer overeenkomen" 79 | 80 | #: src/ZfcUser/language/msgIds.php:22 81 | msgid "Authentication failed. Please try again." 82 | msgstr "Inloggen mislukt. Probeer het opnieuw." 83 | 84 | #: view/zfc-user/user/login.phtml:31 85 | msgid "Not registered?" 86 | msgstr "Niet geregistreerd?" 87 | 88 | #: view/zfc-user/user/login.phtml:31 89 | msgid "Sign up!" 90 | msgstr "Registreren!" 91 | 92 | #: view/zfc-user/user/changeemail.phtml:1 93 | #, php-format 94 | msgid "Change Email for %s" 95 | msgstr "Wijzig het e-mail adres van %s" 96 | 97 | #: view/zfc-user/user/changeemail.phtml:3 98 | msgid "Email address changed successfully." 99 | msgstr "Het e-mail adres is gewijzigd." 100 | 101 | #: view/zfc-user/user/changeemail.phtml:5 102 | msgid "Unable to update your email address. Please try again." 103 | msgstr "Het is niet gelukt het e-mail adres te wijzigen. Probeer het nog eens." 104 | 105 | #: view/zfc-user/user/changepassword.phtml:1 106 | #, php-format 107 | msgid "Change Password for %s" 108 | msgstr "Wijzig het wachtwoord van %s" 109 | 110 | #: view/zfc-user/user/changepassword.phtml:3 111 | msgid "Password changed successfully." 112 | msgstr "Het wachtwoord is gewijzigd." 113 | 114 | #: view/zfc-user/user/changepassword.phtml:5 115 | msgid "Unable to update your password. Please try again." 116 | msgstr "Wachtwoord wijzigen mislukt. Probeer het nog eens." 117 | 118 | #: view/zfc-user/user/index.phtml:2 119 | msgid "Hello" 120 | msgstr "Hallo" 121 | 122 | #: view/zfc-user/user/index.phtml:3 123 | msgid "Sign Out" 124 | msgstr "Afmelden" 125 | -------------------------------------------------------------------------------- /src/ZfcUser/language/pl_PL.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZF-Commons/ZfcUser/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/language/pl_PL.mo -------------------------------------------------------------------------------- /src/ZfcUser/language/pl_PL.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: ZfcUser\n" 4 | "Report-Msgid-Bugs-To: zf-devteam@zend.com\n" 5 | "POT-Creation-Date: 2013-11-08 00:38+0100\n" 6 | "PO-Revision-Date: 2014-02-27 13:22+0100\n" 7 | "Last-Translator: Thomas Szteliga \n" 8 | "Language-Team: ZF Contibutors \n" 9 | "Language: pl_PL\n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | 14 | #: src/ZfcUser/language/msgIds.php:6 15 | msgid "Username" 16 | msgstr "Nazwa użytkownika" 17 | 18 | #: src/ZfcUser/language/msgIds.php:7 19 | msgid "Email" 20 | msgstr "E-mail" 21 | 22 | #: src/ZfcUser/language/msgIds.php:8 23 | msgid "New Email" 24 | msgstr "Nowy e-mail" 25 | 26 | #: src/ZfcUser/language/msgIds.php:9 27 | msgid "Verify New Email" 28 | msgstr "Powtórz nowy e-mail" 29 | 30 | #: src/ZfcUser/language/msgIds.php:10 31 | msgid "Display Name" 32 | msgstr "Nazwa wyświetlana" 33 | 34 | #: src/ZfcUser/language/msgIds.php:11 35 | msgid "Password" 36 | msgstr "Hasło" 37 | 38 | #: src/ZfcUser/language/msgIds.php:12 39 | msgid "Password Verify" 40 | msgstr "Powtórz hasło" 41 | 42 | #: src/ZfcUser/language/msgIds.php:13 43 | msgid "Current Password" 44 | msgstr "Aktualne hasło" 45 | 46 | #: src/ZfcUser/language/msgIds.php:14 47 | msgid "Verify New Password" 48 | msgstr "Powtórz nowe hasło" 49 | 50 | #: src/ZfcUser/language/msgIds.php:15 51 | msgid "New Password" 52 | msgstr "Nowe hasło" 53 | 54 | #: src/ZfcUser/language/msgIds.php:16 55 | msgid "Please type the following text" 56 | msgstr "Proszę przepisz następujący tekst" 57 | 58 | #: src/ZfcUser/language/msgIds.php:17 59 | msgid "Submit" 60 | msgstr "Prześlij" 61 | 62 | #: src/ZfcUser/language/msgIds.php:18 view/zfc-user/user/login.phtml:1 63 | msgid "Sign In" 64 | msgstr "Logowanie" 65 | 66 | #: src/ZfcUser/language/msgIds.php:19 view/zfc-user/user/register.phtml:1 67 | msgid "Register" 68 | msgstr "Rejestracja" 69 | 70 | #: src/ZfcUser/language/msgIds.php:20 71 | msgid "No record matching the input was found" 72 | msgstr "Nie znaleziono konta o podanym identyfikatorze" 73 | 74 | #: src/ZfcUser/language/msgIds.php:21 75 | msgid "A record matching the input was found" 76 | msgstr "Konto o podanym identyfikatorze już istnieje" 77 | 78 | #: src/ZfcUser/language/msgIds.php:22 79 | msgid "Authentication failed. Please try again." 80 | msgstr "" 81 | "Logowanie nie powiodło się. " 82 | "Proszę spróbuj ponownie." 83 | 84 | #: view/zfc-user/user/login.phtml:31 85 | msgid "Not registered?" 86 | msgstr "Nie posiadasz konta?" 87 | 88 | #: view/zfc-user/user/login.phtml:31 89 | msgid "Sign up!" 90 | msgstr "Zarejestruj się!" 91 | 92 | #: view/zfc-user/user/changeemail.phtml:1 93 | #, php-format 94 | msgid "Change Email for %s" 95 | msgstr "Zmień e-mail dla %s" 96 | 97 | #: view/zfc-user/user/changeemail.phtml:3 98 | msgid "Email address changed successfully." 99 | msgstr "Pomyślnie zaktualizowano e-mail." 100 | 101 | #: view/zfc-user/user/changeemail.phtml:5 102 | msgid "Unable to update your email address. Please try again." 103 | msgstr "" 104 | "Nie udało się zaktualizować Twojego adresu e-mail. " 105 | "Proszę spróbuj ponownie." 106 | 107 | #: view/zfc-user/user/changepassword.phtml:1 108 | #, php-format 109 | msgid "Change Password for %s" 110 | msgstr "Zmień hasło dla %s" 111 | 112 | #: view/zfc-user/user/changepassword.phtml:3 113 | msgid "Password changed successfully." 114 | msgstr "Pomyślnie zmieniono hasło." 115 | 116 | #: view/zfc-user/user/changepassword.phtml:5 117 | msgid "Unable to update your password. Please try again." 118 | msgstr "" 119 | "Nie udało się zaktualizować Twojego hasła. " 120 | "Proszę spróbuj ponownie." 121 | 122 | #: view/zfc-user/user/index.phtml:2 123 | msgid "Hello" 124 | msgstr "Witaj" 125 | 126 | #: view/zfc-user/user/index.phtml:3 127 | msgid "Sign Out" 128 | msgstr "Wyloguj" 129 | -------------------------------------------------------------------------------- /src/ZfcUser/language/pt_BR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZF-Commons/ZfcUser/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/language/pt_BR.mo -------------------------------------------------------------------------------- /src/ZfcUser/language/pt_BR.po: -------------------------------------------------------------------------------- 1 | # 2 | # Mihailov Vasilievic Filho , 2015. 3 | # 4 | msgid "" 5 | msgstr "" 6 | "Project-Id-Version: ZfcUser\n" 7 | "Report-Msgid-Bugs-To: zf-devteam@zend.com\n" 8 | "POT-Creation-Date: 2013-11-08 00:38+0100\n" 9 | "PO-Revision-Date: 2015-05-21 00:52-0300\n" 10 | "Last-Translator: Mihailov Vasilievic Filho \n" 11 | "Language-Team: ZF Contibutors \n" 12 | "Language: pt_BR\n" 13 | "MIME-Version: 1.0\n" 14 | "Content-Type: text/plain; charset=UTF-8\n" 15 | "X-Generator: Poedit 1.6.10\n" 16 | "Content-Transfer-Encoding: 8bit\n" 17 | 18 | #: src/ZfcUser/language/msgIds.php:6 19 | msgid "Username" 20 | msgstr "Nome de Usuário" 21 | 22 | #: src/ZfcUser/language/msgIds.php:7 23 | msgid "Email" 24 | msgstr "Email" 25 | 26 | #: src/ZfcUser/language/msgIds.php:8 27 | msgid "New Email" 28 | msgstr "Novo email" 29 | 30 | #: src/ZfcUser/language/msgIds.php:9 31 | msgid "Verify New Email" 32 | msgstr "Verificar novo email" 33 | 34 | #: src/ZfcUser/language/msgIds.php:10 35 | msgid "Display Name" 36 | msgstr "Nome de exibição" 37 | 38 | #: src/ZfcUser/language/msgIds.php:11 39 | msgid "Password" 40 | msgstr "Senha" 41 | 42 | #: src/ZfcUser/language/msgIds.php:12 43 | msgid "Password Verify" 44 | msgstr "Verificação de senha" 45 | 46 | #: src/ZfcUser/language/msgIds.php:13 47 | msgid "Current Password" 48 | msgstr "Senha atual" 49 | 50 | #: src/ZfcUser/language/msgIds.php:14 51 | msgid "Verify New Password" 52 | msgstr "Verificar nova senha" 53 | 54 | #: src/ZfcUser/language/msgIds.php:15 55 | msgid "New Password" 56 | msgstr "Nova senha" 57 | 58 | #: src/ZfcUser/language/msgIds.php:16 59 | msgid "Please type the following text" 60 | msgstr "Por favor, digite o seguinte texto" 61 | 62 | #: src/ZfcUser/language/msgIds.php:17 63 | msgid "Submit" 64 | msgstr "Enviar" 65 | 66 | #: src/ZfcUser/language/msgIds.php:18 view/zfc-user/user/login.phtml:1 67 | msgid "Sign In" 68 | msgstr "Iniciar sessão" 69 | 70 | #: src/ZfcUser/language/msgIds.php:19 view/zfc-user/user/register.phtml:1 71 | msgid "Register" 72 | msgstr "Registrar" 73 | 74 | #: src/ZfcUser/language/msgIds.php:20 75 | msgid "No record matching the input was found" 76 | msgstr "Nenhum registro correspondente a entrada foi encontrado." 77 | 78 | #: src/ZfcUser/language/msgIds.php:21 79 | msgid "A record matching the input was found" 80 | msgstr "Um registro correspondente a entrada foi encontrado." 81 | 82 | #: src/ZfcUser/language/msgIds.php:22 83 | msgid "Authentication failed. Please try again." 84 | msgstr "A autenticação falhou. Por favor, tente novamente." 85 | 86 | #: view/zfc-user/user/login.phtml:31 87 | msgid "Not registered?" 88 | msgstr "Não registrado?" 89 | 90 | #: view/zfc-user/user/login.phtml:31 91 | msgid "Sign up!" 92 | msgstr "Inscreva-se!" 93 | 94 | #: view/zfc-user/user/changeemail.phtml:1 95 | #, php-format 96 | msgid "Change Email for %s" 97 | msgstr "Alterar email de %s" 98 | 99 | #: view/zfc-user/user/changeemail.phtml:3 100 | msgid "Email address changed successfully." 101 | msgstr "Endereço de e-mail alterado com sucesso." 102 | 103 | #: view/zfc-user/user/changeemail.phtml:5 104 | msgid "Unable to update your email address. Please try again." 105 | msgstr "" 106 | "Não foi possível atualizar o seu endereço de e-mail. Por favor, tente " 107 | "novamente." 108 | 109 | #: view/zfc-user/user/changepassword.phtml:1 110 | #, php-format 111 | msgid "Change Password for %s" 112 | msgstr "Mudar senha de %s" 113 | 114 | #: view/zfc-user/user/changepassword.phtml:3 115 | msgid "Password changed successfully." 116 | msgstr "Senha alterada com sucesso." 117 | 118 | #: view/zfc-user/user/changepassword.phtml:5 119 | msgid "Unable to update your password. Please try again." 120 | msgstr "Não foi possível atualizar a senha. Por favor, tente novamente." 121 | 122 | #: view/zfc-user/user/index.phtml:2 123 | msgid "Hello" 124 | msgstr "Olá" 125 | 126 | #: view/zfc-user/user/index.phtml:3 127 | msgid "Sign Out" 128 | msgstr "Sair" 129 | -------------------------------------------------------------------------------- /src/ZfcUser/language/ru_RU.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZF-Commons/ZfcUser/03c8d818807e5edf9cdc723a5460d6ed8ce9c550/src/ZfcUser/language/ru_RU.mo -------------------------------------------------------------------------------- /src/ZfcUser/language/ru_RU.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: ZfcUser\n" 4 | "Report-Msgid-Bugs-To: zf-devteam@zend.com\n" 5 | "POT-Creation-Date: 2013-07-22 12:24+0300\n" 6 | "PO-Revision-Date: 2014-02-27 15:48+0100\n" 7 | "Last-Translator: eugenzor \n" 8 | "Language-Team: ZF Contibutors \n" 9 | "Language: ru_RU\n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | 14 | #: src/ZfcUser/language/msgIds.php:6 15 | msgid "Username" 16 | msgstr "Логин" 17 | 18 | #: src/ZfcUser/language/msgIds.php:7 19 | msgid "Email" 20 | msgstr "Email" 21 | 22 | #: src/ZfcUser/language/msgIds.php:8 23 | msgid "New Email" 24 | msgstr "Новый email" 25 | 26 | #: src/ZfcUser/language/msgIds.php:9 27 | msgid "Verify New Email" 28 | msgstr "Подтвердите новый email" 29 | 30 | #: src/ZfcUser/language/msgIds.php:10 31 | msgid "Display Name" 32 | msgstr "Отображаемое имя" 33 | 34 | #: src/ZfcUser/language/msgIds.php:11 35 | msgid "Password" 36 | msgstr "Пароль" 37 | 38 | #: src/ZfcUser/language/msgIds.php:12 39 | msgid "Password Verify" 40 | msgstr "Подтверждение пароля" 41 | 42 | #: src/ZfcUser/language/msgIds.php:13 43 | msgid "Current Password" 44 | msgstr "Текущий пароль" 45 | 46 | #: src/ZfcUser/language/msgIds.php:14 47 | msgid "Verify New Password" 48 | msgstr "Подтверждение нового пароля" 49 | 50 | #: src/ZfcUser/language/msgIds.php:15 51 | msgid "New Password" 52 | msgstr "Новый пароль" 53 | 54 | #: src/ZfcUser/language/msgIds.php:16 55 | msgid "Please type the following text" 56 | msgstr "Пожалуйста, введите следующий текст" 57 | 58 | #: src/ZfcUser/language/msgIds.php:17 59 | msgid "Submit" 60 | msgstr "Отправить" 61 | 62 | #: src/ZfcUser/language/msgIds.php:18 view/zfc-user/user/login.phtml:1 63 | msgid "Sign In" 64 | msgstr "Вход" 65 | 66 | #: src/ZfcUser/language/msgIds.php:19 view/zfc-user/user/register.phtml:1 67 | msgid "Register" 68 | msgstr "Регистрация" 69 | 70 | #: src/ZfcUser/language/msgIds.php:20 71 | msgid "No record matching the input was found" 72 | msgstr "Нет записей, соответствующих вашему запросу" 73 | 74 | #: src/ZfcUser/language/msgIds.php:21 75 | msgid "A record matching the input was found" 76 | msgstr "Найдена запись, соответствующая вашему запросу" 77 | 78 | #: src/ZfcUser/language/msgIds.php:22 79 | msgid "Authentication failed. Please try again." 80 | msgstr "" 81 | "Ошибка авторизации. " 82 | "Пожалуйста, попробуйте еще раз." 83 | 84 | #: view/zfc-user/user/login.phtml:31 85 | msgid "Not registered?" 86 | msgstr "Зарегистрированы?" 87 | 88 | #: view/zfc-user/user/login.phtml:31 89 | msgid "Sign up!" 90 | msgstr "Регистрация" 91 | 92 | #: view/zfc-user/user/changeemail.phtml:1 93 | #, php-format 94 | msgid "Change Email for %s" 95 | msgstr "Изменить email для %s" 96 | 97 | #: view/zfc-user/user/changeemail.phtml:3 98 | msgid "Email address changed successfully." 99 | msgstr "Email успешно изменен" 100 | 101 | #: view/zfc-user/user/changeemail.phtml:5 102 | msgid "Unable to update your email address. Please try again." 103 | msgstr "" 104 | "Не могу изменить email. " 105 | "Пожалуйста, попробуйте еще раз." 106 | 107 | #: view/zfc-user/user/changepassword.phtml:1 108 | #, php-format 109 | msgid "Change Password for %s" 110 | msgstr "Изменить пароль для %s" 111 | 112 | #: view/zfc-user/user/changepassword.phtml:3 113 | msgid "Password changed successfully." 114 | msgstr "Пароль успешно изменен" 115 | 116 | #: view/zfc-user/user/changepassword.phtml:5 117 | msgid "Unable to update your password. Please try again." 118 | msgstr "" 119 | "Не могу изменить пароль. " 120 | "Пожалуйста, попробуйте еще раз." 121 | 122 | #: view/zfc-user/user/index.phtml:2 123 | msgid "Hello" 124 | msgstr "Привет" 125 | 126 | #: view/zfc-user/user/index.phtml:3 127 | msgid "Sign Out" 128 | msgstr "Выйти" 129 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Authentication/Adapter/AbstractAdapterTest.php: -------------------------------------------------------------------------------- 1 | adapter = new AbstractAdapterExtension(); 19 | } 20 | 21 | /** 22 | * @covers \ZfcUser\Authentication\Adapter\AbstractAdapter::getStorage 23 | */ 24 | public function testGetStorageWithoutStorageSet() 25 | { 26 | $this->assertInstanceOf('Zend\Authentication\Storage\Session', $this->adapter->getStorage()); 27 | } 28 | 29 | /** 30 | * @covers \ZfcUser\Authentication\Adapter\AbstractAdapter::getStorage 31 | * @covers \ZfcUser\Authentication\Adapter\AbstractAdapter::setStorage 32 | */ 33 | public function testSetGetStorage() 34 | { 35 | $storage = new \Zend\Authentication\Storage\Session('ZfcUser'); 36 | $storage->write('zfcUser'); 37 | $this->adapter->setStorage($storage); 38 | 39 | $this->assertInstanceOf('Zend\Authentication\Storage\Session', $this->adapter->getStorage()); 40 | $this->assertSame('zfcUser', $this->adapter->getStorage()->read()); 41 | } 42 | 43 | /** 44 | * @covers \ZfcUser\Authentication\Adapter\AbstractAdapter::isSatisfied 45 | */ 46 | public function testIsSatisfied() 47 | { 48 | $this->assertFalse($this->adapter->isSatisfied()); 49 | } 50 | 51 | public function testSetSatisfied() 52 | { 53 | $result = $this->adapter->setSatisfied(); 54 | $this->assertInstanceOf('ZfcUser\Authentication\Adapter\AbstractAdapter', $result); 55 | $this->assertTrue($this->adapter->isSatisfied()); 56 | 57 | $result = $this->adapter->setSatisfied(false); 58 | $this->assertInstanceOf('ZfcUser\Authentication\Adapter\AbstractAdapter', $result); 59 | $this->assertFalse($this->adapter->isSatisfied()); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Authentication/Adapter/AdapterChainEventTest.php: -------------------------------------------------------------------------------- 1 | event = new AdapterChainEvent(); 22 | } 23 | 24 | /** 25 | * @covers \ZfcUser\Authentication\Adapter\AdapterChainEvent::getCode 26 | * @covers \ZfcUser\Authentication\Adapter\AdapterChainEvent::setCode 27 | * @covers \ZfcUser\Authentication\Adapter\AdapterChainEvent::getMessages 28 | * @covers \ZfcUser\Authentication\Adapter\AdapterChainEvent::setMessages 29 | */ 30 | public function testCodeAndMessages() 31 | { 32 | $testCode = 103; 33 | $testMessages = array('Message recieved loud and clear.'); 34 | 35 | $this->event->setCode($testCode); 36 | $this->assertEquals($testCode, $this->event->getCode(), "Asserting code values match."); 37 | 38 | $this->event->setMessages($testMessages); 39 | $this->assertEquals($testMessages, $this->event->getMessages(), "Asserting messages values match."); 40 | } 41 | 42 | /** 43 | * @depends testCodeAndMessages 44 | * @covers \ZfcUser\Authentication\Adapter\AdapterChainEvent::getIdentity 45 | * @covers \ZfcUser\Authentication\Adapter\AdapterChainEvent::setIdentity 46 | */ 47 | public function testIdentity() 48 | { 49 | $testCode = 123; 50 | $testMessages = array('The message.'); 51 | $testIdentity = 'the_user'; 52 | 53 | $this->event->setCode($testCode); 54 | $this->event->setMessages($testMessages); 55 | 56 | $this->event->setIdentity($testIdentity); 57 | 58 | $this->assertEquals($testCode, $this->event->getCode(), "Asserting the code persisted."); 59 | $this->assertEquals($testMessages, $this->event->getMessages(), "Asserting the messages persisted."); 60 | $this->assertEquals($testIdentity, $this->event->getIdentity(), "Asserting the identity matches"); 61 | 62 | $this->event->setIdentity(); 63 | 64 | $this->assertNull($this->event->getCode(), "Asserting the code has been cleared."); 65 | $this->assertEquals(array(), $this->event->getMessages(), "Asserting the messages have been cleared."); 66 | $this->assertNull($this->event->getIdentity(), "Asserting the identity has been cleared"); 67 | } 68 | 69 | public function testRequest() 70 | { 71 | $request = $this->getMock('Zend\Stdlib\RequestInterface'); 72 | $this->event->setRequest($request); 73 | 74 | $this->assertInstanceOf('Zend\Stdlib\RequestInterface', $this->event->getRequest()); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Authentication/Adapter/AdapterChainServiceFactoryTest.php: -------------------------------------------------------------------------------- 1 | serviceLocatorArray[$index]; 37 | } 38 | 39 | /** 40 | * Prepare the object to be tested. 41 | */ 42 | protected function setUp() 43 | { 44 | $this->serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface'); 45 | 46 | $this->options = $this->getMockBuilder('ZfcUser\Options\ModuleOptions') 47 | ->disableOriginalConstructor() 48 | ->getMock(); 49 | 50 | $this->serviceLocatorArray = array ( 51 | 'zfcuser_module_options'=>$this->options 52 | ); 53 | 54 | $this->serviceLocator->expects($this->any()) 55 | ->method('get') 56 | ->will($this->returnCallback(array($this,'helperServiceLocator'))); 57 | 58 | $this->eventManager = $this->getMock('Zend\EventManager\EventManager'); 59 | 60 | $this->factory = new AdapterChainServiceFactory(); 61 | } 62 | 63 | /** 64 | * @covers \ZfcUser\Authentication\Adapter\AdapterChainServiceFactory::createService 65 | */ 66 | public function testCreateService() 67 | { 68 | $adapter = array( 69 | 'adapter1'=> $this->getMock( 70 | 'ZfcUser\Authentication\Adapter\AbstractAdapter', 71 | array('authenticate', 'logout') 72 | ), 73 | 'adapter2'=> $this->getMock( 74 | 'ZfcUser\Authentication\Adapter\AbstractAdapter', 75 | array('authenticate', 'logout') 76 | ) 77 | ); 78 | $adapterNames = array(100=>'adapter1', 200=>'adapter2'); 79 | 80 | $this->serviceLocatorArray = array_merge($this->serviceLocatorArray, $adapter); 81 | 82 | $this->options->expects($this->once()) 83 | ->method('getAuthAdapters') 84 | ->will($this->returnValue($adapterNames)); 85 | 86 | $adapterChain = $this->factory->__invoke($this->serviceLocator, 'ZfcUser\Authentication\Adapter\AdapterChain'); 87 | 88 | $this->assertInstanceOf('ZfcUser\Authentication\Adapter\AdapterChain', $adapterChain); 89 | } 90 | 91 | /** 92 | * @covers \ZfcUser\Authentication\Adapter\AdapterChainServiceFactory::setOptions 93 | * @covers \ZfcUser\Authentication\Adapter\AdapterChainServiceFactory::getOptions 94 | */ 95 | public function testGetOptionWithSetter() 96 | { 97 | $this->factory->setOptions($this->options); 98 | 99 | $options = $this->factory->getOptions(); 100 | 101 | $this->assertInstanceOf('ZfcUser\Options\ModuleOptions', $options); 102 | $this->assertSame($this->options, $options); 103 | 104 | 105 | $options2 = clone $this->options; 106 | $this->factory->setOptions($options2); 107 | $options = $this->factory->getOptions(); 108 | 109 | $this->assertInstanceOf('ZfcUser\Options\ModuleOptions', $options); 110 | $this->assertNotSame($this->options, $options); 111 | $this->assertSame($options2, $options); 112 | } 113 | 114 | /** 115 | * @covers \ZfcUser\Authentication\Adapter\AdapterChainServiceFactory::getOptions 116 | */ 117 | public function testGetOptionWithLocator() 118 | { 119 | $options = $this->factory->getOptions($this->serviceLocator); 120 | 121 | $this->assertInstanceOf('ZfcUser\Options\ModuleOptions', $options); 122 | $this->assertSame($this->options, $options); 123 | } 124 | 125 | /** 126 | * @covers \ZfcUser\Authentication\Adapter\AdapterChainServiceFactory::getOptions 127 | * @expectedException \ZfcUser\Authentication\Adapter\Exception\OptionsNotFoundException 128 | */ 129 | public function testGetOptionFailing() 130 | { 131 | $options = $this->factory->getOptions(); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Authentication/Adapter/TestAsset/AbstractAdapterExtension.php: -------------------------------------------------------------------------------- 1 | SUT = new Plugin(); 33 | $this->mockedAuthenticationService = $this->getMock('Zend\Authentication\AuthenticationService'); 34 | $this->mockedAuthenticationAdapter = $this->getMockForAbstractClass('\ZfcUser\Authentication\Adapter\AdapterChain'); 35 | } 36 | 37 | 38 | /** 39 | * @covers ZfcUser\Controller\Plugin\ZfcUserAuthentication::hasIdentity 40 | * @covers ZfcUser\Controller\Plugin\ZfcUserAuthentication::getIdentity 41 | */ 42 | public function testGetAndHasIdentity() 43 | { 44 | $this->SUT->setAuthService($this->mockedAuthenticationService); 45 | 46 | $callbackIndex = 0; 47 | $callback = function () use (&$callbackIndex) { 48 | $callbackIndex++; 49 | return (bool) ($callbackIndex % 2); 50 | }; 51 | 52 | $this->mockedAuthenticationService->expects($this->any()) 53 | ->method('hasIdentity') 54 | ->will($this->returnCallback($callback)); 55 | 56 | $this->mockedAuthenticationService->expects($this->any()) 57 | ->method('getIdentity') 58 | ->will($this->returnCallback($callback)); 59 | 60 | $this->assertTrue($this->SUT->hasIdentity()); 61 | $this->assertFalse($this->SUT->hasIdentity()); 62 | $this->assertTrue($this->SUT->hasIdentity()); 63 | 64 | $callbackIndex= 0; 65 | 66 | $this->assertTrue($this->SUT->getIdentity()); 67 | $this->assertFalse($this->SUT->getIdentity()); 68 | $this->assertTrue($this->SUT->getIdentity()); 69 | } 70 | 71 | /** 72 | * @covers ZfcUser\Controller\Plugin\ZfcUserAuthentication::setAuthAdapter 73 | * @covers ZfcUser\Controller\Plugin\ZfcUserAuthentication::getAuthAdapter 74 | */ 75 | public function testSetAndGetAuthAdapter() 76 | { 77 | $adapter1 = $this->mockedAuthenticationAdapter; 78 | $adapter2 = new AdapterChain(); 79 | $this->SUT->setAuthAdapter($adapter1); 80 | 81 | $this->assertInstanceOf('\Zend\Authentication\Adapter\AdapterInterface', $this->SUT->getAuthAdapter()); 82 | $this->assertSame($adapter1, $this->SUT->getAuthAdapter()); 83 | 84 | $this->SUT->setAuthAdapter($adapter2); 85 | 86 | $this->assertInstanceOf('\Zend\Authentication\Adapter\AdapterInterface', $this->SUT->getAuthAdapter()); 87 | $this->assertNotSame($adapter1, $this->SUT->getAuthAdapter()); 88 | $this->assertSame($adapter2, $this->SUT->getAuthAdapter()); 89 | } 90 | 91 | /** 92 | * @covers ZfcUser\Controller\Plugin\ZfcUserAuthentication::setAuthService 93 | * @covers ZfcUser\Controller\Plugin\ZfcUserAuthentication::getAuthService 94 | */ 95 | public function testSetAndGetAuthService() 96 | { 97 | $service1 = new AuthenticationService(); 98 | $service2 = new AuthenticationService(); 99 | $this->SUT->setAuthService($service1); 100 | 101 | $this->assertInstanceOf('\Zend\Authentication\AuthenticationService', $this->SUT->getAuthService()); 102 | $this->assertSame($service1, $this->SUT->getAuthService()); 103 | 104 | $this->SUT->setAuthService($service2); 105 | 106 | $this->assertInstanceOf('\Zend\Authentication\AuthenticationService', $this->SUT->getAuthService()); 107 | $this->assertNotSame($service1, $this->SUT->getAuthService()); 108 | $this->assertSame($service2, $this->SUT->getAuthService()); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Entity/UserTest.php: -------------------------------------------------------------------------------- 1 | user = $user; 15 | } 16 | 17 | /** 18 | * @covers ZfcUser\Entity\User::setId 19 | * @covers ZfcUser\Entity\User::getId 20 | */ 21 | public function testSetGetId() 22 | { 23 | $this->user->setId(1); 24 | $this->assertEquals(1, $this->user->getId()); 25 | } 26 | 27 | /** 28 | * @covers ZfcUser\Entity\User::setUsername 29 | * @covers ZfcUser\Entity\User::getUsername 30 | */ 31 | public function testSetGetUsername() 32 | { 33 | $this->user->setUsername('zfcUser'); 34 | $this->assertEquals('zfcUser', $this->user->getUsername()); 35 | } 36 | 37 | /** 38 | * @covers ZfcUser\Entity\User::setDisplayName 39 | * @covers ZfcUser\Entity\User::getDisplayName 40 | */ 41 | public function testSetGetDisplayName() 42 | { 43 | $this->user->setDisplayName('Zfc User'); 44 | $this->assertEquals('Zfc User', $this->user->getDisplayName()); 45 | } 46 | 47 | /** 48 | * @covers ZfcUser\Entity\User::setEmail 49 | * @covers ZfcUser\Entity\User::getEmail 50 | */ 51 | public function testSetGetEmail() 52 | { 53 | $this->user->setEmail('zfcUser@zfcUser.com'); 54 | $this->assertEquals('zfcUser@zfcUser.com', $this->user->getEmail()); 55 | } 56 | 57 | /** 58 | * @covers ZfcUser\Entity\User::setPassword 59 | * @covers ZfcUser\Entity\User::getPassword 60 | */ 61 | public function testSetGetPassword() 62 | { 63 | $this->user->setPassword('zfcUser'); 64 | $this->assertEquals('zfcUser', $this->user->getPassword()); 65 | } 66 | 67 | /** 68 | * @covers ZfcUser\Entity\User::setState 69 | * @covers ZfcUser\Entity\User::getState 70 | */ 71 | public function testSetGetState() 72 | { 73 | $this->user->setState(1); 74 | $this->assertEquals(1, $this->user->getState()); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Factory/Form/ChangeEmailFormFactoryTest.php: -------------------------------------------------------------------------------- 1 | [ 16 | 'zfcuser_module_options' => new ModuleOptions, 17 | 'zfcuser_user_mapper' => new UserMapper 18 | ] 19 | ]); 20 | 21 | $formElementManager = new FormElementManager($serviceManager); 22 | $serviceManager->setService('FormElementManager', $formElementManager); 23 | 24 | $factory = new ChangeEmailFactory(); 25 | 26 | $this->assertInstanceOf('ZfcUser\Form\ChangeEmail', $factory->__invoke($serviceManager, 'ZfcUser\Form\ChangeEmail')); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Factory/Form/ChangePasswordFormFactoryTest.php: -------------------------------------------------------------------------------- 1 | setService('zfcuser_module_options', new ModuleOptions); 16 | $serviceManager->setService('zfcuser_user_mapper', new UserMapper); 17 | 18 | $formElementManager = new FormElementManager($serviceManager); 19 | $serviceManager->setService('FormElementManager', $formElementManager); 20 | 21 | $factory = new ChangePasswordFactory(); 22 | 23 | $this->assertInstanceOf('ZfcUser\Form\ChangePassword', $factory->__invoke($serviceManager, 'ZfcUser\Form\ChangePassword')); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Factory/Form/LoginFormFactoryTest.php: -------------------------------------------------------------------------------- 1 | setService('zfcuser_module_options', new ModuleOptions); 15 | 16 | $formElementManager = new FormElementManager($serviceManager); 17 | $serviceManager->setService('FormElementManager', $formElementManager); 18 | 19 | $factory = new LoginFactory(); 20 | 21 | $this->assertInstanceOf('ZfcUser\Form\Login', $factory->__invoke($serviceManager, 'ZfcUser\Form\Login')); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Factory/Form/RegisterFormFactoryTest.php: -------------------------------------------------------------------------------- 1 | setService('zfcuser_module_options', new ModuleOptions); 17 | $serviceManager->setService('zfcuser_user_mapper', new UserMapper); 18 | $serviceManager->setService('zfcuser_register_form_hydrator', new ClassMethods()); 19 | 20 | $formElementManager = new FormElementManager($serviceManager); 21 | $serviceManager->setService('FormElementManager', $formElementManager); 22 | 23 | $factory = new RegisterFactory(); 24 | 25 | $this->assertInstanceOf('ZfcUser\Form\Register', $factory->__invoke($serviceManager, 'ZfcUser\Form\Register')); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Form/BaseTest.php: -------------------------------------------------------------------------------- 1 | getElements(); 14 | 15 | $this->assertArrayHasKey('username', $elements); 16 | $this->assertArrayHasKey('email', $elements); 17 | $this->assertArrayHasKey('display_name', $elements); 18 | $this->assertArrayHasKey('password', $elements); 19 | $this->assertArrayHasKey('passwordVerify', $elements); 20 | $this->assertArrayHasKey('submit', $elements); 21 | $this->assertArrayHasKey('userId', $elements); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Form/ChangeEmailFilterTest.php: -------------------------------------------------------------------------------- 1 | getMock('ZfcUser\Options\ModuleOptions'); 12 | $options->expects($this->once()) 13 | ->method('getAuthIdentityFields') 14 | ->will($this->returnValue(array('email'))); 15 | 16 | $validator = $this->getMockBuilder('ZfcUser\Validator\NoRecordExists')->disableOriginalConstructor()->getMock(); 17 | $filter = new Filter($options, $validator); 18 | 19 | $inputs = $filter->getInputs(); 20 | $this->assertArrayHasKey('identity', $inputs); 21 | $this->assertArrayHasKey('newIdentity', $inputs); 22 | $this->assertArrayHasKey('newIdentityVerify', $inputs); 23 | 24 | $validators = $inputs['identity']->getValidatorChain()->getValidators(); 25 | $this->assertArrayHasKey('instance', $validators[0]); 26 | $this->assertInstanceOf('\Zend\Validator\EmailAddress', $validators[0]['instance']); 27 | } 28 | 29 | /** 30 | * @dataProvider providerTestConstructIdentityEmail 31 | */ 32 | public function testConstructIdentityEmail($onlyEmail) 33 | { 34 | $options = $this->getMock('ZfcUser\Options\ModuleOptions'); 35 | $options->expects($this->once()) 36 | ->method('getAuthIdentityFields') 37 | ->will($this->returnValue(($onlyEmail) ? array('email') : array('username'))); 38 | 39 | $validator = $this->getMockBuilder('ZfcUser\Validator\NoRecordExists')->disableOriginalConstructor()->getMock(); 40 | $filter = new Filter($options, $validator); 41 | 42 | $inputs = $filter->getInputs(); 43 | $this->assertArrayHasKey('identity', $inputs); 44 | $this->assertArrayHasKey('newIdentity', $inputs); 45 | $this->assertArrayHasKey('newIdentityVerify', $inputs); 46 | 47 | $identity = $inputs['identity']; 48 | 49 | if ($onlyEmail === false) { 50 | $this->assertEquals(0, $inputs['identity']->getValidatorChain()->count()); 51 | } else { 52 | // test email as identity 53 | $validators = $identity->getValidatorChain()->getValidators(); 54 | $this->assertArrayHasKey('instance', $validators[0]); 55 | $this->assertInstanceOf('\Zend\Validator\EmailAddress', $validators[0]['instance']); 56 | } 57 | } 58 | 59 | public function testSetGetEmailValidator() 60 | { 61 | $options = $this->getMock('ZfcUser\Options\ModuleOptions'); 62 | $options->expects($this->once()) 63 | ->method('getAuthIdentityFields') 64 | ->will($this->returnValue(array())); 65 | 66 | $validatorInit = $this->getMockBuilder('ZfcUser\Validator\NoRecordExists')->disableOriginalConstructor()->getMock(); 67 | $validatorNew = $this->getMockBuilder('ZfcUser\Validator\NoRecordExists')->disableOriginalConstructor()->getMock(); 68 | 69 | $filter = new Filter($options, $validatorInit); 70 | 71 | $this->assertSame($validatorInit, $filter->getEmailValidator()); 72 | $filter->setEmailValidator($validatorNew); 73 | $this->assertSame($validatorNew, $filter->getEmailValidator()); 74 | } 75 | 76 | public function providerTestConstructIdentityEmail() 77 | { 78 | return array( 79 | array(true), 80 | array(false) 81 | ); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Form/ChangeEmailTest.php: -------------------------------------------------------------------------------- 1 | getMock('ZfcUser\Options\AuthenticationOptionsInterface'); 15 | 16 | $form = new Form(null, $options); 17 | 18 | $elements = $form->getElements(); 19 | 20 | $this->assertArrayHasKey('identity', $elements); 21 | $this->assertArrayHasKey('newIdentity', $elements); 22 | $this->assertArrayHasKey('newIdentityVerify', $elements); 23 | $this->assertArrayHasKey('credential', $elements); 24 | } 25 | 26 | /** 27 | * @covers ZfcUser\Form\ChangeEmail::getAuthenticationOptions 28 | * @covers ZfcUser\Form\ChangeEmail::setAuthenticationOptions 29 | */ 30 | public function testSetGetAuthenticationOptions() 31 | { 32 | $options = $this->getMock('ZfcUser\Options\AuthenticationOptionsInterface'); 33 | $form = new Form(null, $options); 34 | 35 | $this->assertSame($options, $form->getAuthenticationOptions()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Form/ChangePasswordFilterTest.php: -------------------------------------------------------------------------------- 1 | getMock('ZfcUser\Options\ModuleOptions'); 12 | $options->expects($this->once()) 13 | ->method('getAuthIdentityFields') 14 | ->will($this->returnValue(array('email'))); 15 | 16 | $filter = new Filter($options); 17 | 18 | $inputs = $filter->getInputs(); 19 | $this->assertArrayHasKey('identity', $inputs); 20 | $this->assertArrayHasKey('credential', $inputs); 21 | $this->assertArrayHasKey('newCredential', $inputs); 22 | $this->assertArrayHasKey('newCredentialVerify', $inputs); 23 | 24 | $validators = $inputs['identity']->getValidatorChain()->getValidators(); 25 | $this->assertArrayHasKey('instance', $validators[0]); 26 | $this->assertInstanceOf('\Zend\Validator\EmailAddress', $validators[0]['instance']); 27 | } 28 | 29 | /** 30 | * @dataProvider providerTestConstructIdentityEmail 31 | */ 32 | public function testConstructIdentityEmail($onlyEmail) 33 | { 34 | $options = $this->getMock('ZfcUser\Options\ModuleOptions'); 35 | $options->expects($this->once()) 36 | ->method('getAuthIdentityFields') 37 | ->will($this->returnValue($onlyEmail ? array('email') : array('username'))); 38 | 39 | $filter = new Filter($options); 40 | 41 | $inputs = $filter->getInputs(); 42 | $this->assertArrayHasKey('identity', $inputs); 43 | $this->assertArrayHasKey('credential', $inputs); 44 | $this->assertArrayHasKey('newCredential', $inputs); 45 | $this->assertArrayHasKey('newCredentialVerify', $inputs); 46 | 47 | $identity = $inputs['identity']; 48 | 49 | if ($onlyEmail === false) { 50 | $this->assertEquals(0, $inputs['identity']->getValidatorChain()->count()); 51 | } else { 52 | // test email as identity 53 | $validators = $identity->getValidatorChain()->getValidators(); 54 | $this->assertArrayHasKey('instance', $validators[0]); 55 | $this->assertInstanceOf('\Zend\Validator\EmailAddress', $validators[0]['instance']); 56 | } 57 | } 58 | 59 | public function providerTestConstructIdentityEmail() 60 | { 61 | return array( 62 | array(true), 63 | array(false) 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Form/ChangePasswordTest.php: -------------------------------------------------------------------------------- 1 | getMock('ZfcUser\Options\AuthenticationOptionsInterface'); 15 | 16 | $form = new Form(null, $options); 17 | 18 | $elements = $form->getElements(); 19 | 20 | $this->assertArrayHasKey('identity', $elements); 21 | $this->assertArrayHasKey('credential', $elements); 22 | $this->assertArrayHasKey('newCredential', $elements); 23 | $this->assertArrayHasKey('newCredentialVerify', $elements); 24 | } 25 | 26 | /** 27 | * @covers ZfcUser\Form\ChangePassword::getAuthenticationOptions 28 | * @covers ZfcUser\Form\ChangePassword::setAuthenticationOptions 29 | */ 30 | public function testSetGetAuthenticationOptions() 31 | { 32 | $options = $this->getMock('ZfcUser\Options\AuthenticationOptionsInterface'); 33 | $form = new Form(null, $options); 34 | 35 | $this->assertSame($options, $form->getAuthenticationOptions()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Form/LoginFilterTest.php: -------------------------------------------------------------------------------- 1 | getMock('ZfcUser\Options\ModuleOptions'); 15 | $options->expects($this->once()) 16 | ->method('getAuthIdentityFields') 17 | ->will($this->returnValue(array())); 18 | 19 | $filter = new Filter($options); 20 | 21 | $inputs = $filter->getInputs(); 22 | $this->assertArrayHasKey('identity', $inputs); 23 | $this->assertArrayHasKey('credential', $inputs); 24 | 25 | $this->assertEquals(0, $inputs['identity']->getValidatorChain()->count()); 26 | } 27 | 28 | /** 29 | * @covers ZfcUser\Form\LoginFilter::__construct 30 | */ 31 | public function testConstructIdentityEmail() 32 | { 33 | $options = $this->getMock('ZfcUser\Options\ModuleOptions'); 34 | $options->expects($this->once()) 35 | ->method('getAuthIdentityFields') 36 | ->will($this->returnValue(array('email'))); 37 | 38 | $filter = new Filter($options); 39 | 40 | $inputs = $filter->getInputs(); 41 | $this->assertArrayHasKey('identity', $inputs); 42 | $this->assertArrayHasKey('credential', $inputs); 43 | 44 | $identity = $inputs['identity']; 45 | 46 | // test email as identity 47 | $validators = $identity->getValidatorChain()->getValidators(); 48 | $this->assertArrayHasKey('instance', $validators[0]); 49 | $this->assertInstanceOf('\Zend\Validator\EmailAddress', $validators[0]['instance']); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Form/LoginTest.php: -------------------------------------------------------------------------------- 1 | getMock('ZfcUser\Options\AuthenticationOptionsInterface'); 16 | $options->expects($this->once()) 17 | ->method('getAuthIdentityFields') 18 | ->will($this->returnValue($authIdentityFields)); 19 | 20 | $form = new Form(null, $options); 21 | 22 | $elements = $form->getElements(); 23 | 24 | $this->assertArrayHasKey('identity', $elements); 25 | $this->assertArrayHasKey('credential', $elements); 26 | 27 | $expectedLabel=""; 28 | if (count($authIdentityFields) > 0) { 29 | foreach ($authIdentityFields as $field) { 30 | $expectedLabel .= ($expectedLabel=="") ? '' : ' or '; 31 | $expectedLabel .= ucfirst($field); 32 | $this->assertContains(ucfirst($field), $elements['identity']->getLabel()); 33 | } 34 | } 35 | 36 | $this->assertEquals($expectedLabel, $elements['identity']->getLabel()); 37 | } 38 | 39 | /** 40 | * @covers ZfcUser\Form\Login::getAuthenticationOptions 41 | * @covers ZfcUser\Form\Login::setAuthenticationOptions 42 | */ 43 | public function testSetGetAuthenticationOptions() 44 | { 45 | $options = $this->getMock('ZfcUser\Options\AuthenticationOptionsInterface'); 46 | $options->expects($this->once()) 47 | ->method('getAuthIdentityFields') 48 | ->will($this->returnValue(array())); 49 | $form = new Form(null, $options); 50 | 51 | $this->assertSame($options, $form->getAuthenticationOptions()); 52 | } 53 | 54 | public function providerTestConstruct() 55 | { 56 | return array( 57 | array(array()), 58 | array(array('email')), 59 | array(array('username','email')), 60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Form/RegisterFilterTest.php: -------------------------------------------------------------------------------- 1 | getMock('ZfcUser\Options\ModuleOptions'); 15 | $options->expects($this->once()) 16 | ->method('getEnableUsername') 17 | ->will($this->returnValue(true)); 18 | $options->expects($this->once()) 19 | ->method('getEnableDisplayName') 20 | ->will($this->returnValue(true)); 21 | 22 | $emailValidator = $this->getMockBuilder('ZfcUser\Validator\NoRecordExists')->disableOriginalConstructor()->getMock(); 23 | $usernameValidator = $this->getMockBuilder('ZfcUser\Validator\NoRecordExists')->disableOriginalConstructor()->getMock(); 24 | 25 | $filter = new Filter($emailValidator, $usernameValidator, $options); 26 | 27 | $inputs = $filter->getInputs(); 28 | $this->assertArrayHasKey('username', $inputs); 29 | $this->assertArrayHasKey('email', $inputs); 30 | $this->assertArrayHasKey('display_name', $inputs); 31 | $this->assertArrayHasKey('password', $inputs); 32 | $this->assertArrayHasKey('passwordVerify', $inputs); 33 | } 34 | 35 | public function testSetGetEmailValidator() 36 | { 37 | $options = $this->getMock('ZfcUser\Options\ModuleOptions'); 38 | $validatorInit = $this->getMockBuilder('ZfcUser\Validator\NoRecordExists')->disableOriginalConstructor()->getMock(); 39 | $validatorNew = $this->getMockBuilder('ZfcUser\Validator\NoRecordExists')->disableOriginalConstructor()->getMock(); 40 | 41 | $filter = new Filter($validatorInit, $validatorInit, $options); 42 | 43 | $this->assertSame($validatorInit, $filter->getEmailValidator()); 44 | $filter->setEmailValidator($validatorNew); 45 | $this->assertSame($validatorNew, $filter->getEmailValidator()); 46 | } 47 | 48 | public function testSetGetUsernameValidator() 49 | { 50 | $options = $this->getMock('ZfcUser\Options\ModuleOptions'); 51 | $validatorInit = $this->getMockBuilder('ZfcUser\Validator\NoRecordExists')->disableOriginalConstructor()->getMock(); 52 | $validatorNew = $this->getMockBuilder('ZfcUser\Validator\NoRecordExists')->disableOriginalConstructor()->getMock(); 53 | 54 | $filter = new Filter($validatorInit, $validatorInit, $options); 55 | 56 | $this->assertSame($validatorInit, $filter->getUsernameValidator()); 57 | $filter->setUsernameValidator($validatorNew); 58 | $this->assertSame($validatorNew, $filter->getUsernameValidator()); 59 | } 60 | 61 | public function testSetGetOptions() 62 | { 63 | $options = $this->getMock('ZfcUser\Options\ModuleOptions'); 64 | $optionsNew = $this->getMock('ZfcUser\Options\ModuleOptions'); 65 | $validatorInit = $this->getMockBuilder('ZfcUser\Validator\NoRecordExists')->disableOriginalConstructor()->getMock(); 66 | $filter = new Filter($validatorInit, $validatorInit, $options); 67 | 68 | $this->assertSame($options, $filter->getOptions()); 69 | $filter->setOptions($optionsNew); 70 | $this->assertSame($optionsNew, $filter->getOptions()); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Form/RegisterTest.php: -------------------------------------------------------------------------------- 1 | getMock('ZfcUser\Options\RegistrationOptionsInterface'); 15 | $options->expects($this->once()) 16 | ->method('getEnableUsername') 17 | ->will($this->returnValue(false)); 18 | $options->expects($this->once()) 19 | ->method('getEnableDisplayName') 20 | ->will($this->returnValue(false)); 21 | $options->expects($this->any()) 22 | ->method('getUseRegistrationFormCaptcha') 23 | ->will($this->returnValue($useCaptcha)); 24 | if ($useCaptcha && class_exists('\Zend\Captcha\AbstractAdapter')) { 25 | $captcha = $this->getMockForAbstractClass('\Zend\Captcha\AbstractAdapter'); 26 | 27 | $options->expects($this->once()) 28 | ->method('getFormCaptchaOptions') 29 | ->will($this->returnValue($captcha)); 30 | } 31 | 32 | $form = new Form(null, $options); 33 | 34 | $elements = $form->getElements(); 35 | 36 | $this->assertArrayNotHasKey('userId', $elements); 37 | $this->assertArrayNotHasKey('username', $elements); 38 | $this->assertArrayNotHasKey('display_name', $elements); 39 | $this->assertArrayHasKey('email', $elements); 40 | $this->assertArrayHasKey('password', $elements); 41 | $this->assertArrayHasKey('passwordVerify', $elements); 42 | } 43 | 44 | public function providerTestConstruct() 45 | { 46 | return array( 47 | array(true), 48 | array(false) 49 | ); 50 | } 51 | 52 | public function testSetGetRegistrationOptions() 53 | { 54 | $options = $this->getMock('ZfcUser\Options\RegistrationOptionsInterface'); 55 | $options->expects($this->once()) 56 | ->method('getEnableUsername') 57 | ->will($this->returnValue(false)); 58 | $options->expects($this->once()) 59 | ->method('getEnableDisplayName') 60 | ->will($this->returnValue(false)); 61 | $options->expects($this->any()) 62 | ->method('getUseRegistrationFormCaptcha') 63 | ->will($this->returnValue(false)); 64 | $form = new Form(null, $options); 65 | 66 | $this->assertSame($options, $form->getRegistrationOptions()); 67 | 68 | $optionsNew = $this->getMock('ZfcUser\Options\RegistrationOptionsInterface'); 69 | $form->setRegistrationOptions($optionsNew); 70 | $this->assertSame($optionsNew, $form->getRegistrationOptions()); 71 | } 72 | 73 | public function testSetCaptchaElement() 74 | { 75 | $options = $this->getMock('ZfcUser\Options\RegistrationOptionsInterface'); 76 | $options->expects($this->once()) 77 | ->method('getEnableUsername') 78 | ->will($this->returnValue(false)); 79 | $options->expects($this->once()) 80 | ->method('getEnableDisplayName') 81 | ->will($this->returnValue(false)); 82 | $options->expects($this->any()) 83 | ->method('getUseRegistrationFormCaptcha') 84 | ->will($this->returnValue(false)); 85 | 86 | $captcha = $this->getMock('\Zend\Form\Element\Captcha'); 87 | $form = new Form(null, $options); 88 | 89 | $form->setCaptchaElement($captcha); 90 | 91 | $reflection = $this->helperMakePropertyAccessable($form, 'captchaElement'); 92 | $this->assertSame($captcha, $reflection->getValue($form)); 93 | } 94 | 95 | 96 | /** 97 | * 98 | * @param mixed $objectOrClass 99 | * @param string $property 100 | * @param mixed $value = null 101 | * @return \ReflectionProperty 102 | */ 103 | public function helperMakePropertyAccessable($objectOrClass, $property, $value = null) 104 | { 105 | $reflectionProperty = new \ReflectionProperty($objectOrClass, $property); 106 | $reflectionProperty->setAccessible(true); 107 | 108 | if ($value !== null) { 109 | $reflectionProperty->setValue($objectOrClass, $value); 110 | } 111 | return $reflectionProperty; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Mapper/UserHydratorTest.php: -------------------------------------------------------------------------------- 1 | hydrator = $hydrator; 15 | } 16 | 17 | /** 18 | * @covers ZfcUser\Mapper\UserHydrator::extract 19 | * @expectedException ZfcUser\Mapper\Exception\InvalidArgumentException 20 | */ 21 | public function testExtractWithInvalidUserObject() 22 | { 23 | $user = new \StdClass; 24 | $this->hydrator->extract($user); 25 | } 26 | 27 | /** 28 | * @covers ZfcUser\Mapper\UserHydrator::extract 29 | * @covers ZfcUser\Mapper\UserHydrator::mapField 30 | * @dataProvider dataProviderTestExtractWithValidUserObject 31 | * @see https://github.com/ZF-Commons/ZfcUser/pull/421 32 | */ 33 | public function testExtractWithValidUserObject($object, $expectArray) 34 | { 35 | $result = $this->hydrator->extract($object); 36 | $this->assertEquals($expectArray, $result); 37 | } 38 | 39 | /** 40 | * @covers ZfcUser\Mapper\UserHydrator::hydrate 41 | * @expectedException ZfcUser\Mapper\Exception\InvalidArgumentException 42 | */ 43 | public function testHydrateWithInvalidUserObject() 44 | { 45 | $user = new \StdClass; 46 | $this->hydrator->hydrate(array(), $user); 47 | } 48 | 49 | /** 50 | * @covers ZfcUser\Mapper\UserHydrator::hydrate 51 | * @covers ZfcUser\Mapper\UserHydrator::mapField 52 | */ 53 | public function testHydrateWithValidUserObject() 54 | { 55 | $user = new \ZfcUser\Entity\User; 56 | 57 | $expectArray = array( 58 | 'username' => 'zfcuser', 59 | 'email' => 'Zfc User', 60 | 'display_name' => 'ZfcUser', 61 | 'password' => 'ZfcUserPassword', 62 | 'state' => 1, 63 | 'user_id' => 1 64 | ); 65 | 66 | $result = $this->hydrator->hydrate($expectArray, $user); 67 | 68 | $this->assertEquals($expectArray['username'], $result->getUsername()); 69 | $this->assertEquals($expectArray['email'], $result->getEmail()); 70 | $this->assertEquals($expectArray['display_name'], $result->getDisplayName()); 71 | $this->assertEquals($expectArray['password'], $result->getPassword()); 72 | $this->assertEquals($expectArray['state'], $result->getState()); 73 | $this->assertEquals($expectArray['user_id'], $result->getId()); 74 | } 75 | 76 | public function dataProviderTestExtractWithValidUserObject() 77 | { 78 | $createUserObject = function ($data) { 79 | $user = new \ZfcUser\Entity\User; 80 | foreach ($data as $key => $value) { 81 | if ($key == 'user_id') { 82 | $key='id'; 83 | } 84 | $methode = 'set' . str_replace(" ", "", ucwords(str_replace("_", " ", $key))); 85 | call_user_func(array($user,$methode), $value); 86 | } 87 | return $user; 88 | }; 89 | $return = array(); 90 | $expectArray = array(); 91 | 92 | $buffer = array( 93 | 'username' => 'zfcuser', 94 | 'email' => 'Zfc User', 95 | 'display_name' => 'ZfcUser', 96 | 'password' => 'ZfcUserPassword', 97 | 'state' => 1, 98 | 'user_id' => 1 99 | ); 100 | 101 | $return[]=array($createUserObject($buffer), $buffer); 102 | 103 | /** 104 | * @see https://github.com/ZF-Commons/ZfcUser/pull/421 105 | */ 106 | $buffer = array( 107 | 'username' => 'zfcuser', 108 | 'email' => 'Zfc User', 109 | 'display_name' => 'ZfcUser', 110 | 'password' => 'ZfcUserPassword', 111 | 'state' => 1 112 | ); 113 | 114 | $return[]=array($createUserObject($buffer), $buffer); 115 | 116 | return $return; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Mapper/_files/user.sql: -------------------------------------------------------------------------------- 1 | 2 | INSERT INTO user (username,email,display_name,password,state) 3 | VALUES ('zfc-user', 'zfc-user@github.com', 'Zfc-User', 'zfc-user',1); 4 | 5 | INSERT INTO user (username,email,display_name,password,state) 6 | VALUES ('zfc-user2', 'zfc-user2@github.com', 'Zfc-User2', 'zfc-user2',1); 7 | 8 | INSERT INTO user (username,email,display_name,password,state) 9 | VALUES ('zfc-user3', 'zfc-user@trash-mail.com', 'Zfc-User3', 'zfc-user3',1); 10 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Validator/AbstractRecordTest.php: -------------------------------------------------------------------------------- 1 | 'value'); 15 | new AbstractRecordExtension($options); 16 | } 17 | 18 | /** 19 | * @covers ZfcUser\Validator\AbstractRecord::__construct 20 | * @expectedException ZfcUser\Validator\Exception\InvalidArgumentException 21 | * @expectedExceptionMessage No key provided 22 | */ 23 | public function testConstructEmptyArray() 24 | { 25 | $options = array(); 26 | new AbstractRecordExtension($options); 27 | } 28 | 29 | /** 30 | * @covers ZfcUser\Validator\AbstractRecord::getMapper 31 | * @covers ZfcUser\Validator\AbstractRecord::setMapper 32 | */ 33 | public function testGetSetMapper() 34 | { 35 | $options = array('key' => ''); 36 | $validator = new AbstractRecordExtension($options); 37 | 38 | $this->assertNull($validator->getMapper()); 39 | 40 | $mapper = $this->getMock('ZfcUser\Mapper\UserInterface'); 41 | $validator->setMapper($mapper); 42 | $this->assertSame($mapper, $validator->getMapper()); 43 | } 44 | 45 | /** 46 | * @covers ZfcUser\Validator\AbstractRecord::getKey 47 | * @covers ZfcUser\Validator\AbstractRecord::setKey 48 | */ 49 | public function testGetSetKey() 50 | { 51 | $options = array('key' => 'username'); 52 | $validator = new AbstractRecordExtension($options); 53 | 54 | $this->assertEquals('username', $validator->getKey()); 55 | 56 | $validator->setKey('email'); 57 | $this->assertEquals('email', $validator->getKey()); 58 | } 59 | 60 | /** 61 | * @covers ZfcUser\Validator\AbstractRecord::query 62 | * @expectedException \Exception 63 | * @expectedExceptionMessage Invalid key used in ZfcUser validator 64 | */ 65 | public function testQueryWithInvalidKey() 66 | { 67 | $options = array('key' => 'zfcUser'); 68 | $validator = new AbstractRecordExtension($options); 69 | 70 | $method = new \ReflectionMethod('ZfcUserTest\Validator\TestAsset\AbstractRecordExtension', 'query'); 71 | $method->setAccessible(true); 72 | 73 | $method->invoke($validator, array('test')); 74 | } 75 | 76 | /** 77 | * @covers ZfcUser\Validator\AbstractRecord::query 78 | */ 79 | public function testQueryWithKeyUsername() 80 | { 81 | $options = array('key' => 'username'); 82 | $validator = new AbstractRecordExtension($options); 83 | 84 | $mapper = $this->getMock('ZfcUser\Mapper\UserInterface'); 85 | $mapper->expects($this->once()) 86 | ->method('findByUsername') 87 | ->with('test') 88 | ->will($this->returnValue('ZfcUser')); 89 | 90 | $validator->setMapper($mapper); 91 | 92 | $method = new \ReflectionMethod('ZfcUserTest\Validator\TestAsset\AbstractRecordExtension', 'query'); 93 | $method->setAccessible(true); 94 | 95 | $result = $method->invoke($validator, 'test'); 96 | 97 | $this->assertEquals('ZfcUser', $result); 98 | } 99 | 100 | /** 101 | * @covers ZfcUser\Validator\AbstractRecord::query 102 | */ 103 | public function testQueryWithKeyEmail() 104 | { 105 | $options = array('key' => 'email'); 106 | $validator = new AbstractRecordExtension($options); 107 | 108 | $mapper = $this->getMock('ZfcUser\Mapper\UserInterface'); 109 | $mapper->expects($this->once()) 110 | ->method('findByEmail') 111 | ->with('test@test.com') 112 | ->will($this->returnValue('ZfcUser')); 113 | 114 | $validator->setMapper($mapper); 115 | 116 | $method = new \ReflectionMethod('ZfcUserTest\Validator\TestAsset\AbstractRecordExtension', 'query'); 117 | $method->setAccessible(true); 118 | 119 | $result = $method->invoke($validator, 'test@test.com'); 120 | 121 | $this->assertEquals('ZfcUser', $result); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Validator/NoRecordExistsTest.php: -------------------------------------------------------------------------------- 1 | 'username'); 16 | $validator = new Validator($options); 17 | $this->validator = $validator; 18 | 19 | $mapper = $this->getMock('ZfcUser\Mapper\UserInterface'); 20 | $this->mapper = $mapper; 21 | 22 | $validator->setMapper($mapper); 23 | } 24 | 25 | /** 26 | * @covers ZfcUser\Validator\NoRecordExists::isValid 27 | */ 28 | public function testIsValid() 29 | { 30 | $this->mapper->expects($this->once()) 31 | ->method('findByUsername') 32 | ->with('zfcUser') 33 | ->will($this->returnValue(false)); 34 | 35 | $result = $this->validator->isValid('zfcUser'); 36 | $this->assertTrue($result); 37 | } 38 | 39 | /** 40 | * @covers ZfcUser\Validator\NoRecordExists::isValid 41 | */ 42 | public function testIsInvalid() 43 | { 44 | $this->mapper->expects($this->once()) 45 | ->method('findByUsername') 46 | ->with('zfcUser') 47 | ->will($this->returnValue('zfcUser')); 48 | 49 | $result = $this->validator->isValid('zfcUser'); 50 | $this->assertFalse($result); 51 | 52 | $options = $this->validator->getOptions(); 53 | $this->assertArrayHasKey(\ZfcUser\Validator\AbstractRecord::ERROR_RECORD_FOUND, $options['messages']); 54 | $this->assertEquals($options['messageTemplates'][\ZfcUser\Validator\AbstractRecord::ERROR_RECORD_FOUND], $options['messages'][\ZfcUser\Validator\AbstractRecord::ERROR_RECORD_FOUND]); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Validator/RecordExistsTest.php: -------------------------------------------------------------------------------- 1 | 'username'); 16 | $validator = new Validator($options); 17 | $this->validator = $validator; 18 | 19 | $mapper = $this->getMock('ZfcUser\Mapper\UserInterface'); 20 | $this->mapper = $mapper; 21 | 22 | $validator->setMapper($mapper); 23 | } 24 | 25 | /** 26 | * @covers ZfcUser\Validator\RecordExists::isValid 27 | */ 28 | public function testIsValid() 29 | { 30 | $this->mapper->expects($this->once()) 31 | ->method('findByUsername') 32 | ->with('zfcUser') 33 | ->will($this->returnValue('zfcUser')); 34 | 35 | $result = $this->validator->isValid('zfcUser'); 36 | $this->assertTrue($result); 37 | } 38 | 39 | /** 40 | * @covers ZfcUser\Validator\RecordExists::isValid 41 | */ 42 | public function testIsInvalid() 43 | { 44 | $this->mapper->expects($this->once()) 45 | ->method('findByUsername') 46 | ->with('zfcUser') 47 | ->will($this->returnValue(false)); 48 | 49 | $result = $this->validator->isValid('zfcUser'); 50 | $this->assertFalse($result); 51 | 52 | $options = $this->validator->getOptions(); 53 | $this->assertArrayHasKey(\ZfcUser\Validator\AbstractRecord::ERROR_NO_RECORD_FOUND, $options['messages']); 54 | $this->assertEquals($options['messageTemplates'][\ZfcUser\Validator\AbstractRecord::ERROR_NO_RECORD_FOUND], $options['messages'][\ZfcUser\Validator\AbstractRecord::ERROR_NO_RECORD_FOUND]); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/Validator/TestAsset/AbstractRecordExtension.php: -------------------------------------------------------------------------------- 1 | helper = $helper; 17 | 18 | $authService = $this->getMock('Zend\Authentication\AuthenticationService'); 19 | $this->authService = $authService; 20 | 21 | $helper->setAuthService($authService); 22 | } 23 | 24 | /** 25 | * @covers ZfcUser\View\Helper\ZfcUserIdentity::__invoke 26 | */ 27 | public function testInvokeWithIdentity() 28 | { 29 | $this->authService->expects($this->once()) 30 | ->method('hasIdentity') 31 | ->will($this->returnValue(true)); 32 | $this->authService->expects($this->once()) 33 | ->method('getIdentity') 34 | ->will($this->returnValue('zfcUser')); 35 | 36 | $result = $this->helper->__invoke(); 37 | 38 | $this->assertEquals('zfcUser', $result); 39 | } 40 | 41 | /** 42 | * @covers ZfcUser\View\Helper\ZfcUserIdentity::__invoke 43 | */ 44 | public function testInvokeWithoutIdentity() 45 | { 46 | $this->authService->expects($this->once()) 47 | ->method('hasIdentity') 48 | ->will($this->returnValue(false)); 49 | 50 | $result = $this->helper->__invoke(); 51 | 52 | $this->assertFalse($result); 53 | } 54 | 55 | /** 56 | * @covers ZfcUser\View\Helper\ZfcUserIdentity::setAuthService 57 | * @covers ZfcUser\View\Helper\ZfcUserIdentity::getAuthService 58 | */ 59 | public function testSetGetAuthService() 60 | { 61 | //We set the authservice in setUp, so we dont have to set it again 62 | $this->assertSame($this->authService, $this->helper->getAuthService()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /tests/ZfcUserTest/View/Helper/ZfcUserLoginWidgetTest.php: -------------------------------------------------------------------------------- 1 | helper = new ViewHelper; 17 | 18 | $view = $this->getMock('Zend\View\Renderer\RendererInterface'); 19 | $this->view = $view; 20 | 21 | $this->helper->setView($view); 22 | } 23 | 24 | public function providerTestInvokeWithRender() 25 | { 26 | $attr = array(); 27 | $attr[] = array( 28 | array( 29 | 'render' => true, 30 | 'redirect' => 'zfcUser' 31 | ), 32 | array( 33 | 'loginForm' => null, 34 | 'redirect' => 'zfcUser' 35 | ), 36 | ); 37 | $attr[] = array( 38 | array( 39 | 'redirect' => 'zfcUser' 40 | ), 41 | array( 42 | 'loginForm' => null, 43 | 'redirect' => 'zfcUser' 44 | ), 45 | ); 46 | $attr[] = array( 47 | array( 48 | 'render' => true, 49 | ), 50 | array( 51 | 'loginForm' => null, 52 | 'redirect' => false 53 | ), 54 | ); 55 | 56 | return $attr; 57 | } 58 | 59 | /** 60 | * @covers ZfcUser\View\Helper\ZfcUserLoginWidget::__invoke 61 | * @dataProvider providerTestInvokeWithRender 62 | */ 63 | public function testInvokeWithRender($option, $expect) 64 | { 65 | /** 66 | * @var $viewModel \Zend\View\Model\ViewModels 67 | */ 68 | $viewModel = null; 69 | 70 | $this->view->expects($this->at(0)) 71 | ->method('render') 72 | ->will($this->returnCallback(function ($vm) use (&$viewModel) { 73 | $viewModel = $vm; 74 | return "test"; 75 | })); 76 | 77 | $result = $this->helper->__invoke($option); 78 | 79 | $this->assertNotInstanceOf('Zend\View\Model\ViewModel', $result); 80 | $this->assertInternalType('string', $result); 81 | 82 | 83 | $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); 84 | foreach ($expect as $name => $value) { 85 | $this->assertEquals($value, $viewModel->getVariable($name, "testDefault")); 86 | } 87 | } 88 | 89 | /** 90 | * @covers ZfcUser\View\Helper\ZfcUserLoginWidget::__invoke 91 | */ 92 | public function testInvokeWithoutRender() 93 | { 94 | $result = $this->helper->__invoke(array( 95 | 'render' => false, 96 | 'redirect' => 'zfcUser' 97 | )); 98 | 99 | $this->assertInstanceOf('Zend\View\Model\ViewModel', $result); 100 | $this->assertEquals('zfcUser', $result->redirect); 101 | } 102 | 103 | /** 104 | * @covers ZfcUser\View\Helper\ZfcUserLoginWidget::setLoginForm 105 | * @covers ZfcUser\View\Helper\ZfcUserLoginWidget::getLoginForm 106 | */ 107 | public function testSetGetLoginForm() 108 | { 109 | $loginForm = $this->getMockBuilder('ZfcUser\Form\Login')->disableOriginalConstructor()->getMock(); 110 | 111 | $this->helper->setLoginForm($loginForm); 112 | $this->assertInstanceOf('ZfcUser\Form\Login', $this->helper->getLoginForm()); 113 | } 114 | 115 | /** 116 | * @covers ZfcUser\View\Helper\ZfcUserLoginWidget::setViewTemplate 117 | */ 118 | public function testSetViewTemplate() 119 | { 120 | $this->helper->setViewTemplate('zfcUser'); 121 | 122 | $reflectionClass = new \ReflectionClass('ZfcUser\View\Helper\ZfcUserLoginWidget'); 123 | $reflectionProperty = $reflectionClass->getProperty('viewTemplate'); 124 | $reflectionProperty->setAccessible(true); 125 | 126 | $this->assertEquals('zfcUser', $reflectionProperty->getValue($this->helper)); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | add('ZfcUserTest', __DIR__); 15 | 16 | if (!$config = @include 'configuration.php') { 17 | $config = require 'configuration.php.dist'; 18 | } 19 | -------------------------------------------------------------------------------- /tests/configuration.php.dist: -------------------------------------------------------------------------------- 1 | 12 | 13 | ./ZfcUserTest 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | ../src 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /view/zfc-user/user/_form.phtml: -------------------------------------------------------------------------------- 1 | form()->openTag($form) ?> 2 |
3 | 4 | getLabel() != null && !$element instanceof Zend\Form\Element\Button) : ?> 5 |
formLabel($element) ?>
6 | 7 |
formElement($element) . $this->formElementErrors($element) ?>
8 | 9 |
10 | redirect) : ?> 11 | 12 | 13 | form()->closeTag() ?> -------------------------------------------------------------------------------- /view/zfc-user/user/changeemail.phtml: -------------------------------------------------------------------------------- 1 |

translate('Change Email for %s'), $this->zfcUserDisplayName()); ?>

2 | 3 |
translate('Email address changed successfully.'); ?>
4 | 5 |
translate('Unable to update your email address. Please try again.'); ?>
6 | 7 | changeEmailForm; 10 | 11 | $form->prepare(); 12 | $form->setAttribute('action', $this->url('zfcuser/changeemail')); 13 | $form->setAttribute('method', 'post'); 14 | ?> 15 | 16 | partial('_form.phtml', ['form' => $form]); ?> 17 | -------------------------------------------------------------------------------- /view/zfc-user/user/changepassword.phtml: -------------------------------------------------------------------------------- 1 |

translate('Change Password for %s'), $this->zfcUserDisplayName()); ?>

2 | 3 |
translate('Password changed successfully.');?>
4 | 5 |
translate('Unable to update your password. Please try again.'); ?>
6 | 7 | changePasswordForm; 10 | 11 | $form->prepare(); 12 | $form->setAttribute('action', $this->url('zfcuser/changepassword')); 13 | $form->setAttribute('method', 'post'); 14 | $form->setAttribute('autocomplete', 'off'); 15 | 16 | $emailElement = $form->get('identity'); 17 | $emailElement->setValue($this->zfcUserIdentity()->getEmail()); 18 | ?> 19 | 20 | partial('_form.phtml', ['form' => $form]); ?> 21 | -------------------------------------------------------------------------------- /view/zfc-user/user/index.phtml: -------------------------------------------------------------------------------- 1 |
gravatar($this->zfcUserIdentity()->getEmail()) ?>
2 |

translate('Hello'); ?>, zfcUserDisplayName() ?>!

3 | [translate('Sign Out'); ?>] 4 |
5 | -------------------------------------------------------------------------------- /view/zfc-user/user/login.phtml: -------------------------------------------------------------------------------- 1 |

translate('Sign In'); ?>

2 | 3 | loginForm; 5 | $form->prepare(); 6 | $form->setAttribute('action', $this->url('zfcuser/login')); 7 | $form->setAttribute('method', 'post'); 8 | $form->setAttribute('autocomplete', 'off'); 9 | ?> 10 | 11 | partial('_form.phtml', ['form' => $form]); ?> 12 | 13 | enableRegistration) : ?> 14 | translate('Not registered?'); ?> translate('Sign up!'); ?> 15 | 16 | -------------------------------------------------------------------------------- /view/zfc-user/user/register.phtml: -------------------------------------------------------------------------------- 1 |

translate('Register'); ?>

2 | 3 | enableRegistration) { 5 | print "Registration is disabled"; 6 | return; 7 | } 8 | $form = $this->registerForm; 9 | $form->prepare(); 10 | $form->setAttribute('action', $this->url('zfcuser/register')); 11 | $form->setAttribute('method', 'post'); 12 | $form->setAttribute('autocomplete', 'off'); 13 | ?> 14 | 15 | partial('_form.phtml', ['form' => $form]); ?> 16 | --------------------------------------------------------------------------------