This release contains a few small updates and bug fixes. Most notably, I've changed
LoginForm.username
to LoginForm.email
and added a timezone field to app\models\Profile
(thanks mnglkhn)
To upgrade to this version:
-
Change all references of
LoginForm.username
toLoginForm.email
. This would be in the model and view files that you extended -
Optional - Add a
timezone
column to profile table in the database -
Optional - Add validation rules / attribute label (lines 29 and 59) for
timezone
field in Profile model
This release is a major code overhaul. Lots of refactoring, cleaning up, updating comments, etc. Aside from the migration, the other changes apply to any code that you've extended from the module.
(Note: This list may not be entirely comprehensive ... If I forgot something, please let me know)
-
Back up your database
-
Download migration and run it
cd /path/to/app/migrations
wget https://gist.githubusercontent.com/amnah/384e607f5e2d3cbfbc72/raw/f420380ea0e0ca4d73e7fc1ab2bba11377913868/m151111_122541_upgrade_user_300_to_400.php
cd /path/to/app
php yii migrate
-
Change table references
UserKey
toUserToken
-
Change field references
UserToken.key_value
toUserToken.token
-
Change
$key
parameters to$token
in DefaultController functions AND views (eg,actionConfirm($key)
toactionConfirm($token)
andactionReset($key)
toactionReset($token)
) -
Change references
User.new_email
toUserToken.data
This release just has some minor updates, but unfortunately contains backwards-compatibility breaking changes.
To update to this version:
- Change table column
tbl_user_key.key
totbl_user_key.key_value
in your sql database
This release is basically a code overhaul and does not contain any functionality changes. In short, I've updated the code to fit PSR-2 standards and re-created the models/crud via gii (to incorporate the many changes since then).
To sync your app with this version:
(Major changes)
-
Change table name
tbl_userkey
totbl_user_key
in your sql database -
If you extended the DefaultController and/or email view files, change variable names
$userkey
to$userKey
(notice the capitalization of the letter "K") -
If you extended the view files, remove
viewPath
from module configuration and usecomponents => view => theme
instead
// @app/config/web.php
'modules' => [
'user' => [
'viewPath' => '@app/views/user', // REMOVE THIS
],
],
'components' => [
'view' => [
'theme' => [
'pathMap' => [ // SET THIS INSTEAD
'@vendor/amnah/yii2-user/views' => '@app/themes/user', // example: @app/themes/user/default/profile.php
],
],
],
],
- If you overrode
DefaultController::actionReset()
,models\forms\ResetForm
, or thedefault/reset.php
view file, you will need to change the references of$model
to$user
. This is because the ResetForm model has been removed, and the reset functionality now uses the User model instead (with scenario "reset").
(Minor changes - you most likely won't need to do these)
-
If you used the guest role, re-add it back into the Role model
const ROLE_GUEST = 3
-
If you overrode
models\User::setLoginIpAndTime()
, change the name tomodels\User::updateLoginMeta()
-
If you overrode
Module::_checkEmailUsername()
, change the name toModule::checkModuleProperties()
-
If you overrode
Module::_getDefaultModelClasses()
, change the name toModule::getDefaultModelClasses()
(no underscore) -
If you overrode
DefaultController::_calcEmailOrLogin()
, change the name toDefaultController::afterRegister()
-
If you overrode
AdminController::actionIndex()
,models\search\UserSearch
, or theadmin/index.php
view file, you will need to check to see if the $profile->full_name works properly. Typically, you would need to change this in the view file:
// views/admin/index.php
// change this
[
'attribute' => 'full_name',
'label' => 'Full Name',
'value' => function($model, $index, $dataColumn) {
return $model->profile->full_name;
}
],
// to this
'profile.full_name',