Download the PHP package azamath/yii-account without Composer
On this page you can find all versions of the php package azamath/yii-account. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download azamath/yii-account
More information about azamath/yii-account
Files in azamath/yii-account
Package yii-account
Short Description Extension that provides basic account functionality for the Yii PHP framework.
License BSD-3-Clause
Informations about the package yii-account
yii-account
Extension that provides basic account functionality for the Yii PHP framework.
Why do I want this
This project was inspired by the [http://github.com/mishamx/yii-user](yii-user module) and was carefully developed with our expertise in Yii following the best practices of the framework. It is more secure because it uses passwords with salt that are encrypted using bcrypt instead of password hashes. It also comes with support for sending mail with truly random authentication tokens that expire.
We are also currently working on additional security features (listed in the requirements below).
User interface
Requirements
- Secure accounts (password + salt) DONE
- Sign up DONE
- Account activation (enabled by default) DONE
- Log in / Log out DONE
- Reset password DONE
- Email sending (with token validation) DONE
- Require new password every x days (disabled by default) DONE
- Password history (encrypted) to prevent from using same password twice DONE
- Lock accounts after x failed login attempts (disabled by default) __DONE___
- Console command for creating accounts DONE
- Proper README WIP
Installation
The easiest way to install this extension is to use Composer.
Run the following command to download the extension:
Add the following to your application configuration:
To use the console command you need to add the following to your console application configuration:
Run the following command to apply database migrations (you need to have a database configured for your application):
Without Composer
If you are not using Composer, then you need to download the dependencies manually and add the following to your application configuration:
Dependencies
- Yiistrap http://github.com/crisu83/yiistrap
- YiiPassword https://github.com/phpnode/yiipassword
- RandomLib https://github.com/ircmaxell/RandomLib
- SecurityLib https://github.com/ircmaxell/SecurityLib
Configuration
The following configurations are available for the class:
- classMap array map over classes to use within the module.
- enableActivation bool whether to enable account activation (defaults to true).
- numAllowedFailedLogins int number of a user can fail to login before the account is locked (defaults to 10)
- loginExpireTime int number of seconds for login cookie to expire (defaults to 30 days).
- activateExpireTime int number of seconds for account activation to expire (defaults to 30 days).
- resetPasswordExpireTime int number of seconds for password reset to expire (defaults to 1 day).
- passwordExpireTime int number of seconds for passwords to expire (defaults to disabled).
- lockoutExpireTime int number of seconds for account lockout to expire (defaults to 10 minutes).
- fromEmailAddress string from e-mail address used when sending mail.
- messageSource string message source component to use for the module.
- registerStyles bool whether to register the default styles.
- defaultLayout string path alias for the layout to use within the module.
Usage
Now you should be able to see the login page when you go to the following url:
You can run the following command to generate an account from the command line:
Extending
This project was developed with a focus on re-usability, so before you start copy-pasting take a moment of your time and read through this section to learn how to extend this module properly.
Custom account model
You can use your own account model as long as you add the following fields to it:
- username varchar(255) not null account username
- password varchar(255) not null account password
- email varchar(255) not null account email
- passwordStrategy varchar(255) not null password encryption type
- requireNewPassword tinyint(1) not null default '0' whether account password must be changed
- createdAt _timestamp null default currenttimestamp when the account was created
- lastActiveAt timestamp null default null when the account was last active
- status int(11) default '0' account status (e.g. inactive, activated)
Changing the model used by the extension is easy, simply configure it to use your class instead by adding it to the class map for the module:
Custom models, components or forms classes
You can use the class map to configure any classes used by the module, here is a complete list of the available classes:
- account models\ar\Account account model
- token models\ar\AccountToken account token mode
- loginHistory models\ar\AccountLoginHistory login history model
- passwordHistory models\ar\AccountPasswordHistory password history model
- userIdentity components\UserIdentity user identity
- loginForm models\form\LoginForm login form
- passwordForm models\form\PasswordForm base form that handles passwords
- signupForm models\form\SignupForm signup form (extends passwordForm)
- forgotPassword models\form\ForgotPasswordForm forgot password form
Custom controllers
If you want to use your own controllers you can map them using the module's controller map:
Custom views
If you want to use your own views with this module you can override the views with your own by placing them either under your application under or your theme under .
Extending the module itself
You may also want to extend the module itself, e.g. in order to implement proper email sending. In that case you can extend the module and override the methods necessary and configure your account to use your module instead:
Normally you would need to copy all the views under your module, but we have made it easy so that you can only override the views you need to and the module will automatically look for the default views under the parent module.
The source code is also quite well documented so the easiest way to find out how to extend properly is to dive into the code and get to know the logic behind the functionality. Also, if you have any ideas for improvements feel free to file an issue or create a pull-request.
Contribute
If you wish to contribute to this project feel free to create a pull-request to the branch.
Run test suite
To run the test suite you need to run the following commands:
Now you can use the following command to run the test suite:
Translate
If you wish to translate this project you can find the translation templates under . When you are done with your translation create a pull-request to the branch.
All versions of yii-account with dependencies
crisu83/yiistrap Version dev-bs3
ircmaxell/random-lib Version v1.0.0