Zend Framework 2 Module
CsnUser is a Module for Authentication based on DoctrineORMModule
CsnUser has been created with educational purposes to demonstrate how Authentication can be done. It is fully functional.
CsnUser module consists of:
- Login with remember me
- Registration with Captcha and Confirmation email
- Forgotten password with confirmation email.
In addition, passwords are encrypted using Bcrypt algorithm.
An alternative to ZfcUser with more functionality added.
-
Installation via composer is supported, simply run:
php composer.phar require coolcsn/csn-user:dev-master
. The installed module is located in ./vendor/coolcsn/csn-user. -
Create Doctrine Proxy cache directory in APP_ROOT/data/DoctrineORMModule/Proxy. Be shure to grant write permissions.
-
Add
CsnUser
,DoctrineModule
andDoctrineORMModule
in your application configuration at:./config/application.config.php
. An example configuration may look like the following :
'modules' => array(
'Application',
'DoctrineModule',
'DoctrineORMModule',
'CsnUser'
)
CsnUser requires setting up a Connection for Doctrine, a simple Mail configuration and importing a database schema.
-
Create a new database (or use an existing one, dedicated to your application).
-
Copy the sample Doctrine configuration from
./vendor/coolcsn/csn-user/config/doctrineorm.local.php.dist
to./config/autoload
renaming it to doctrineorm.local.php. Edit the file, replacing the values (username, password, etc) with your personal database parameters. -
Run
./vendor/bin/doctrine-module orm:schema-tool:create
to generate the database schema. Import the sample SQL data (for some default data) located in./vendor/coolcsn/CsnUser/data/SampleData.sql
. You can easily do that with PhpMyAdmin for instance. -
Copy the sample Mail configuration from
./vendor/coolcsn/csn-user/config/mail.config.local.php.dist
to./config/autoload
renaming it to mail.config.local.php. Edit the file, replacing the values (host, username, etc) with your SMTP server parameters. -
Append the contents of
./vendor/coolcsn/CsnUser/data/CsnUser.css
to APP_ROOT/public/css/styles.css or includeCsnUser.css
into your app.
The CsnUser module has some options to allow you to quickly customize the basic
functionality. After installing CsnUser, copy
./vendor/coolcsn/CsnUser/config/csnuser.global.php.dist
to
./config/autoload
, renaming it to csnuser.global.php and change the values as desired, following the instructions.
The following options are available:
- login_redirect_route String value, name of a route in the application which the user will be redirected to after a successful login.
- logout_redirect_route String value, name of a route in the application which the user will be redirected to after logging out.
- sender_email_adress String value, email address to set From field of generated emails from module
- nav_menu Bool value, show or hide navigation menu.
- captcha_char_num Integer Value, number of captcha characters to display.
- display_exceptions Boolean true/false value, set this to true to view possible exceptions details. If you are in production, then set it to false so exceptions get less verbose.
Navigate to [hostname]/user in your browser to view different options for login, registration, forgotten password, etc.
The following routes are available:
- user Welcome view.
- user/login User login view.
- user/register User register view.
- user/register/reset-password User resep password view.
- user/register/edit-profile User edit profile view.
- user/register/change-password User change password view.
- user/register/change-email User change email view.
- user/register/change-security-question User change security question view.
- user/admin Users admin view.
- user/admin/create User admin create view.
This Module depends on the following Modules:
-
[DoctrineORMModule] (https://github.com/doctrine/DoctrineORMModule) - DoctrineORMModule integrates Doctrine 2 ORM with Zend Framework 2 quickly and easily.
-
coolcsn/CsnAuthorization - Authorization compatible for this Registration and Logging.
-
coolcsn/CsnNavigation - Navigation module;
-
coolcsn/CsnCms - Content management system;