Yii 1.1: yii-user

Yii PHP Framework extension for registration and management users accounts.
218 followers

Yii PHP Framework extension for registration and management users accounts.

  • Login from User Name or Email
  • Registration
  • Activation accounts (verification email, administrator or not)
  • Recovery password (send recovery key to user email)
  • User profile page
  • Manage Users
  • Manage Profile Fields
  • Profile field widget for view, edit and save data
  • Date widget (jQueryUI datepicker)
  • File upload widget
  • Profile Relation Widget
  • API

Resources

Ohloh project report for yii-user

Documentation

Requirements

  • Yii 1.1 or above

Installation

  • Extract the release file under protected
  • Change your config main:
return array(
    #...
    // autoloading model and component classes
    'import'=>array(
        'application.models.*',
        'application.components.*',
        'application.modules.user.models.*',
        'application.modules.user.components.*',
    ),
    #...
    'modules'=>array(
        #...
        'user'=>array(
            # encrypting method (php hash function)
            'hash' => 'md5',
 
            # send activation email
            'sendActivationMail' => true,
 
            # allow access for non-activated users
            'loginNotActiv' => false,
 
            # activate user on registration (only sendActivationMail = false)
            'activeAfterRegister' => false,
 
            # automatically login from registration
            'autoLogin' => true,
 
            # registration path
            'registrationUrl' => array('/user/registration'),
 
            # recovery password path
            'recoveryUrl' => array('/user/recovery'),
 
            # login form path
            'loginUrl' => array('/user/login'),
 
            # page after login
            'returnUrl' => array('/user/profile'),
 
            # page after logout
            'returnLogoutUrl' => array('/user/login'),
        ),
        #...
    ),
    #...
    // application components
    'components'=>array(
    #...
        'db'=>array(
        #...
            'tablePrefix' => 'tbl_',
        #...
        ),
        #...
        'user'=>array(
            // enable cookie-based authentication
            'class' => 'WebUser',
            'allowAutoLogin'=>true,
            'loginUrl' => array('/user/login'),
        ),
    #...
    ),
    #...
);
  • Change your config console:
return array(
    #...
    'modules'=>array(
        #...
        'user'=>array(
            # encrypting method (php hash function)
            'hash' => 'md5',
 
            # send activation email
            'sendActivationMail' => true,
 
            # allow access for non-activated users
            'loginNotActiv' => false,
 
            # activate user on registration (only sendActivationMail = false)
            'activeAfterRegister' => false,
 
            # automatically login from registration
            'autoLogin' => true,
 
            # registration path
            'registrationUrl' => array('/user/registration'),
 
            # recovery password path
            'recoveryUrl' => array('/user/recovery'),
 
            # login form path
            'loginUrl' => array('/user/login'),
 
            # page after login
            'returnUrl' => array('/user/profile'),
 
            # page after logout
            'returnLogoutUrl' => array('/user/login'),
        ),
        #...
    ),
    #...
);
  • Run command: yiic migrate --migrationPath=user.migrations
  • Input admin login, email and password
  • Insert items into zii.widgets.CMenu array (protected/views/layouts/main.php)
array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->registrationUrl, 'label'=>Yii::app()->getModule('user')->t("Register"), 'visible'=>Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->profileUrl, 'label'=>Yii::app()->getModule('user')->t("Profile"), 'visible'=>!Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->logoutUrl, 'label'=>Yii::app()->getModule('user')->t("Logout").' ('.Yii::app()->user->name.')', 'visible'=>!Yii::app()->user->isGuest),

Change Log

  • 2012-06-11 | (HEAD, origin/master, origin/HEAD, master) Readme update - [Mikhail Mangushev]
  • 2012-06-11 | Fixed security bug (thanks jpablo) - [Mikhail Mangushev]
  • 2012-06-07 | Fix marsuboss pullrequest - [Mikhail Mangushev]
  • 2012-06-07 | Merge pull request #4 from marsuboss/master - [mishamx]
  • 2012-06-06 | Add 'Old Password' Field for change password - [DECORTE Jeremy]
  • 2012-05-26 | Merge pull request #3 from rmenor/master - [mishamx]
  • 2012-05-26 | Add DECIMAL type in ProfileField - [rmenor]
  • 2012-05-26 | Repair Issue 45: Field Type Float Won't Accept 10,2 Format - [rmenor]
  • 2012-05-23 | Set default values in migration - [Mikhail Mangushev]
  • 2012-05-23 | Merge branch 'master' of github.com:mishamx/yii-user - [Mikhail Mangushev]
  • 2012-05-23 | Interactive migration added - [Mikhail Mangushev]
  • 2012-05-22 | Merge pull request #2 from phundament/master - [mishamx]
  • 2012-04-19 | fixed alias - [Tobias Munk]
  • 2011-10-30 | Added to the global dictionary translation - [Mikhail Mangushev]
  • 2011-10-19 | Merge pull request #1 from rallin/simple_clone - [mishamx]
  • 2011-10-18 | Update Readme - [rallin]
  • 2011-10-18 | Move files to the root - [rallin]
  • 2011-09-06 | WebUser: comment stat module Migration: added current time - [Mikhail Mangushev]
  • 2011-08-19 | Admin user rules fix - [Mikhail Mangushev]
  • 2011-08-11 | Readmi fix Migraton fix for sqlite - [Mikhail Mangushev]
  • 2011-08-11 | change version - [Mikhail Mangushev]
  • 2011-08-11 | Use local setting for migration - [Mikhail Mangushev]
  • 2011-08-11 | Unixttime fields replaced to timestamp - [Mikhail Mangushev]
  • 2011-08-10 | Readme update - [Mikhail Mangushev]
  • 2011-08-10 | Move migration Use command: yiic migrate --migrationPath=application.modules.user.migrations - [Mikhail Mangushev]
  • 2011-08-08 | Added readme markdown - [Mikhail Mangushev]
  • 2011-08-07 | Yii-User install migration - [Mikhail Mangushev]
  • 2011-08-05 | Added WebUser component - [Mikhail Mangushev]
  • 2011-06-02 | * Update Admin Interface * Fixed issue 60 * Fixed issue 61 * Fixed issue 63 * Fixed issue 77 * Fixed issue 80 * Fixed issue 81 * Fixed
  • 2011-05-31 | Added dutch translation (thanks afj.lamb...@gmail.com) Fixed issue 86 - [Mikhail Mangushev]
  • 2011-04-04 | Polish translation added (thanks aleksand...@gmail.com) Fixed issue 79 - [Mikhail Mangushev]
  • 2011-03-31 | Fixed issue 59 - [Mikhail Mangushev]
  • 2011-03-31 | Fixed issue 75 - [Mikhail Mangushev]
  • 2011-02-23 | Japanese translation (fixed issue 62) - [Mikhail Mangushev]
  • 2011-02-22 | Added Romanian translation (thanks @matricks) - [Mikhail Mangushev]
  • 2011-02-16 | * add multiple validators for profile field (fixed issue 56) * fix delete UWfile error for sqlite - [Mikhail Mangushev]
  • 2011-02-16 | Merge controller filters (fixed issue 55) - [Mikhail Mangushev]
  • 2011-02-16 | Added support of configuring behaviors via module fields (fixed issue 54) - [Mikhail Mangushev]
  • 2011-02-09 | Fixed issue 53 - [Mikhail Mangushev]
  • 2011-02-09 | Fixed issue 47 - [Mikhail Mangushev]
  • 2011-02-09 | Fixed issue 44 - [Mikhail Mangushev]
  • 2011-02-08 | logic fix r97 - [Mikhail Mangushev]
  • 2011-02-08 | Fixed issue 43 - [Mikhail Mangushev]
  • 2011-01-31 | - [Vitaliy Step]
  • 2011-01-27 | Portuguese translation (fixed issue 51) - [Mikhail Mangushev]
  • 2011-01-27 | Fixed issue 49 - [Mikhail Mangushev]
  • 2011-01-27 | Fixed issue 36 - [Mikhail Mangushev]
  • 2011-01-27 | Fixed issue 24 - [Mikhail Mangushev]
  • 2011-01-27 | * Translation fix * Rename translation ua->uk * Added Hungarian (thanks @lupus2001) and Greek (thanks @drumaddict) translation * Added
  • 2011-01-19 | Widgetparams resize - [Mikhail Mangushev]
  • 2010-12-02 | Form validator fix - [Mikhail Mangushev]
  • 2010-11-22 | Fixed issue 46 - [Mikhail Mangushev]
  • 2010-11-15 | AJAX form validation - [Mikhail Mangushev]
  • 2010-11-12 | IE fix - [Mikhail Mangushev]
  • 2010-11-09 | Fixed issue 41 - [Mikhail Mangushev]
  • 2010-11-02 | Fixed issue 39 - [Mikhail Mangushev]
  • 2010-11-02 | Fixed issue 38 - [Mikhail Mangushev]
  • 2010-10-27 | (0.3) Admin edit form fix - [Mikhail Mangushev]
  • 2010-10-27 | Fixed issue 37 - [Mikhail Mangushev]
  • 2010-09-23 | Fixed issue 34 and translation. - [Mikhail Mangushev]
  • 2010-09-23 | Fixed issue 31 - [Mikhail Mangushev]
  • 2010-09-22 | Fixed issue 32 - [Mikhail Mangushev]
  • 2010-09-20 | Added: * Parameters names tables * Parameter disable "captcha" * New mode: activate user by administrator * New mode: activate user
  • 2010-08-03 | fixed Issue #22 - [Mikhail Mangushev]
  • 2010-08-03 | * Added Spanish translation * Fixed issue #18 - [Mikhail Mangushev]
  • 2010-06-30 | fixed recovery form reg exp rules - [Mikhail Mangushev]
  • 2010-06-29 | Fixed: * issue #11 * issue #12 * issue #14 * issue #15 * issue #16 - [Mikhail Mangushev]
  • 2010-03-17 | Fix bug: clear password on login - [Mikhail Mangushev]
  • 2010-02-27 | Added and update: * user relations API * reange (select) - [Mikhail Mangushev]
  • 2010-02-26 | temporarily due to a bug http://code.google.com/p/yii/issues/detail?id=636 - [Mikhail Mangushev]
  • 2010-02-26 | bug fix - [Mikhail Mangushev]
  • 2010-02-26 | fix bug - [Mikhail Mangushev]
  • 2010-02-25 | (0.2) UserModule - [Mikhail Mangushev]
  • 2010-02-25 | ported to module - [Mikhail Mangushev]
  • 2010-02-13 | fix: * issue #3 * issue #4 * Error saving profile: empty activation key - [Mikhail Mangushev]
  • 2010-02-13 | fix Issue #2 - [Mikhail Mangushev]
  • 2010-02-11 | (0.1) Yii-User version 0.1 release. = Features of Yii-User = * Login from User Name or Email * Registration * Activation accounts (v
  • 2010-01-20 | Yii-User version 0.1 (alpha) = Features of Yii-User = * Login from User Name or Email * Registration * Activation accounts

Total 20 comments

#17986 report it
Rajith R at 2014/08/22 01:52am
@begemotik

Great :-)

#17976 report it
begemotik at 2014/08/20 04:40am
Tutorial

Hi,
I've written an extensive tutorial on how to install both hoauth and Yii-user, and modify according to your needs.
I'm hoping this will help someone. You can find the article here.

#17867 report it
Rajith R at 2014/08/02 01:11am
@selorm

Thanks for the info. :-)

#17857 report it
selorm at 2014/07/31 02:41pm
preg_match error on php5.5

due to update to the pcre library on php5.5, yii user outputs this error

preg_match(): Compilation failed: invalid range in character class at offset 15

when using the recovery form. To fix that, just update the pattern on line 23 from

/^[A-Za-z0-9@.-\s,]+$/u

to

/^[A-Za-z0-9@.\-s,]+$/u

, thus making hyphen comes after the backslash. You can use this site debuggex.com to validate it. Got hint after some digging on stackoveflow.Hope it saves your time

#17157 report it
Rajith R at 2014/05/08 07:21am
@propelera

You can also go through this wiki

http://www.yiiframework.com/wiki/423/installing-yii-users-and-rights-to-newly-created-yii-app/

Wiki

#16748 report it
propelera at 2014/03/25 05:20am
missing steps

I had fresh installation of Yii so I had hard time figuring out how to manage my database for yii-user and some other staffs. This tutorial lacks few steps.

use yii-user-0.3-r107.zip version! or download latest update from original yii-user resource

1) Do like this:

  • Run command: yiic migrate --migrationPath=user.migrations (yii from /protected/ folder not from /framework/ folder)

  • Create tables (dump files from folder "protected\modules\user\data" schema.mysql.sql or schema.sqlite.sql)

  • Input admin login, email and password (admin/admin or demo/demo)

2) If you are getting WebUser not defined error, just edit your confing main file

change this:

'user'=>array(
            // enable cookie-based authentication
            'class' => 'WebUser', //remove this line
            'allowAutoLogin'=>true,
            'loginUrl' => array('/user/login'),
        ),

to this:

'user'=>array(
            // enable cookie-based authentication
            'allowAutoLogin'=>true,
            'loginUrl' => array('/user/login'),
        ),

3) Add new rule to urlManager else "edit" and "change password" will not work.

'urlManager'=>array(
            'urlFormat'=>'path',
            'showScriptName' => false,
            'rules'=>array(
...
            // rule for yii-user module, else "Edit" and "Change password" will not work on "profile" page
                'user/<controller:\w+>/<action:\w+>'=>'user/<controller>/<action>',
...
            ),
),

This is another guide you may find it useful

P.S.

A guy called "Derek++" wrote me about some another problem. I don't know if this is problem or not, but this someone might find it useful:

In the latest version of the module the login form's action url is not set and defaults to the index page. To fix...
 
in views/user/login.php on line 21 change this...
 
<?php echo CHtml::beginForm(); ?>
 
to this ...
 
<?php echo CHtml::beginForm(Yii::app()->controller->module->loginUrl); ?>
 
Not sure if this is a Yii issue as technically an empty action should get set to the current page not the index. Btw I'm not using pretty urls so might be an issue with that.
#16745 report it
Rajith R at 2014/03/25 03:37am
@propelera

The default admin login is username : admin , Password : admin

The login url is user/login

#16740 report it
propelera at 2014/03/24 03:46pm
Input admin login, email and password

I have run the command

yiic migrate --migrationPath=user.migrations

and console showed that it is up to date, and now, can you tell me how to Input admin login, email and password? What exactly should I do?

#16542 report it
somploc at 2014/03/04 12:06pm
@mustofa62

check LoginController.php

if (Yii::app()->user->returnUrl=='/index.php') $this->redirect(Yii::app()->controller->module->returnUrl); else $this->redirect(Yii::app()->user->returnUrl);

i set single step : $this->redirect(Yii::app()->user->returnUrl=='/yourUrl');

#16343 report it
leo4all at 2014/02/12 07:05pm
missing file

Need it on ProfileField

$cs->registerScriptFile($baseUrl.'/js/form.js');

#15970 report it
emmi at 2014/01/06 02:22am
how do i use the admin part of yii user

Here I go Currently I can use the yii-user extension registration for normal user how do i use the admin part of yii user extension I am unable to figure out

In yii using yiic migrate command on command prompt can insert the record but then what i need is to give a link to admin wherein he can insert his record. can this happen

please let me know

#15771 report it
teo_ne at 2013/12/16 03:15am
@schmunk

Thank's for the advice.. In these days I've noticed that with some small edit to the extensions (in all the controller when render() is called) I can easily use the views I've created in views/user folder, and so I can easily change the theme in the normal way.

#15492 report it
Rajith R at 2013/11/15 01:46am
@mostofa62

in the login controller inside the user module

if (Yii::app()->user->returnUrl=='/index.php')
$this->redirect(Yii::app()->controller->module->returnUrl);
else
$this->redirect(Yii::app()->user->returnUrl);

check these lines

#15491 report it
Rajith R at 2013/11/15 01:43am
@mostofa62

is 'returnUrl' => array('/user/profile'), this set in the main config file?

#15487 report it
trond at 2013/11/14 06:26am
@mostofa62

I suggest you set a break point and single step through the code to see what happens.

#15486 report it
mostofa62 at 2013/11/14 05:38am
this is not working for me 'returnUrl' => array('/user/profile'),
'returnUrl' => array('/user/profile'),

this is not working for me, means its not redirecting after log in for say i am using rights module also,for authorization and in user component,i am using RWebUser as class

#15208 report it
MistaMoh at 2013/10/17 10:41pm
Translations : and update config file

then of course, in your config file, use :

'class' => 'GTDbMessageSource',

Sorry about the code format failures and double post.

#15207 report it
MistaMoh at 2013/10/17 10:37pm
Hybrid translation : extend XYZMessageSource

@schmunk thanks for the quick reply.

I used a trick close to onMissingTranslation logic. It consists on extending app's regular XYZMessageSource component and dealing with extensions' categories accordingly.

Here's a performant, working but not industrial example in my case :

[code] class GTDbMessageSource extends CDbMessageSource { public function translate($category,$message,$language=null) { if($category=='app') return parent::translate($category,$message,$language); else return (new CPhpMessageSource())->translate($category,$message,$language); }

} [/code]

#15204 report it
schmunk at 2013/10/17 08:43pm
Hybrid Translations

@MistaMoh: We've created a static function which looks for the translation in the message file and inserts it into the database. It can be hooked into the onMissingTranslation event. Please note that enabling the event handler degrades application performance!

Another option would be to parse your catalogs in a Yii command and insert them into the database.

#15203 report it
MistaMoh at 2013/10/17 05:03pm
make yii-user translations work while app uses CDbMessageSource

Hey,

Thanks for the awesome ext. Saves a looooot of time. But I can't get to use its translations.

I'm using CDbMessageSource in my app. When i change my config to enable the default CPhpMessageSource, then the translations work for the module, but obviously not for the rest of my app.

any clue on how to enable hybrid translations engines ?

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: mishamx
  • Category: Auth
  • Votes: +261 / -19
  • Downloaded: 60,673 times
  • Created on: Feb 12, 2010
  • Last updated: Jun 11, 2012
  • Tags: user, module