Giter VIP home page Giter VIP logo

yii-user's Introduction

Yii-User Installation

Download

Download or checkout (SVN/Git) from http://yii-user.2mx.org and unpack files in your protected/modules/user

Git clone

clone git [email protected]:mishamx/yii-user.git

Configure

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',
        ),
    #...
    ),
    #...
);

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'),
        ),
        #...
    ),
    #...
);

Install

Run command: yiic migrate --migrationPath=user.migrations

Input admin login, email and password

yii-user's People

Contributors

alan01252 avatar ametad avatar chalist avatar chris68 avatar crawlerv avatar daris avatar hastenax avatar igorsantos07 avatar infoitservit avatar jfgaviria avatar josiasmontag avatar kirill-dubelevich avatar marsuboss avatar masiorama avatar mishamx avatar nayjest avatar ramoscarlos avatar rdewilde avatar rmenor avatar rsmokov avatar schmunk42 avatar somethingstrange123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii-user's Issues

Call to a member function getAttributes()

Upon registering using hoauth and Facebook or Google I get this error:

Fatal error: Call to a member function getAttributes() on a non-object in ...../protected/modules/user/components/WebUser.php on line 57

I am using git versions of hoauth and yii-user.

I am not sure, it this is problem inside yii-user or hoauth, but I think, that problem is in yii-user.

Problem on the delete action on the ProfileFieldController

Hi, I found out that the execute() command returns 0 affected rows for the drop column.
The $model->delete() is never going to be executed, so the record from the ProfileField table in not going to be deleted.

Maybe there is another way to check if the sql command has been executed but not like that.

$sql = 'ALTER TABLE '.Profile::model()->tableName().' DROP '.$model->varname.'';
if ($model->dbConnection->createCommand($sql)->execute()) {
$model->delete();
}

When deleting ProfileField, tbl_profiles primary key is dropped.

How to reproduce:

  1. Use sqlite database
  2. Create a new profile field
  3. Delete the profile field

What do we see on User module homepage:

Error triggered by CActiveFinder::populateRecord() at line 784:

...
foreach($this->_pkAlias as $name=>$alias)
...

The cause of the error is that Yii does not support database tables with no primary key and when we delete a profile field the table is re-created without primary key.

Here is an issue on the topic: https://code.google.com/p/yii/issues/detail?id=2922

Before deletion of the profile field the table structure is:

CREATE TABLE tbl_profiles (
  user_id INTEGER NOT NULL PRIMARY KEY,
  lastname varchar(50) NOT NULL DEFAULT '',
  firstname varchar(50) NOT NULL DEFAULT '',
  allow_multi_sessions INTEGER NOT NULL DEFAULT '0'
);

After:

CREATE TABLE tbl_profiles (user_id,lastname,firstname)

Most probably the solution will be to fix ProfileFieldController::actionDelete()

migration creates tables named {{users}} {{profiles}} and {{profiles_fields}} and then fails

I ran the migration command as per the readme.md and it failed... here is the output
Creating migration history table "tbl_migration"...done.
Total 2 new migrations to be applied:
m110805_153437_installYiiUser
m110810_162301_userTimestampFix

Apply the above migrations? (yes|no) [no]:yes
*** applying m110805_153437_installYiiUser
type db: mysql
> create table {{users}} ... done (time: 0.093s)
> create unique index user_username on {{users}} (username) ... done (time: 0.165s)
> create unique index user_email on {{users}} (email) ... done (time: 0.103s)
> create table {{profiles}} ... done (time: 0.130s)
> add foreign key user_profile_id: {{profiles}} (user_id) references {{users}} (id) ... done (time: 0.149s)
> create table {{profiles_fields}} ... done (time: 0.109s)
Admin login [admin]:
Admin email [[email protected]]:
Admin password [admin]:
> insert into {{users}} ... done (time: 0.002s)
> insert into {{profiles}} ... done (time: 0.001s)
> insert into {{profiles_fields}} ... done (time: 0.001s)
> insert into {{profiles_fields}} ... done (time: 0.001s)
*** applied m110805_153437_installYiiUser (time: 17.428s)

*** applying m110810_162301_userTimestampFix
type db: mysql
> add column create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP to table {{users}} ... done (time: 0.110s)
> add column lastvisit_at TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' to table {{users}} ... done (time: 0.211s)
> execute SQL: UPDATE {{users}} SET create_at = FROM_UNIXTIME(createtime), lastvisit_at = IF(lastvisit,FROM_UNIXTIME(lastvisit),'0000-00-00 00:00:00') ...Exception: CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '{users}} SET create_at = FROM_UNIXTIME(createtime), lastvisit_at = IF(lastvisit,' at line 1. The SQL statement executed was: UPDATE {{users}} SET create_at = FROM_UNIXTIME(createtime), lastvisit_at = IF(lastvisit,FROM_UNIXTIME(lastvisit),'0000-00-00 00:00:00') (/Applications/MAMP/htdocs/yii-1.1.13.e9e4a0/framework/db/CDbCommand.php:357)
#0 /Applications/MAMP/htdocs/yii-1.1.13.e9e4a0/framework/db/CDbMigration.php(159): CDbCommand->execute(Array)
#1 /Applications/MAMP/htdocs/yii1.1/protected/modules/user/migrations/m110810_162301_userTimestampFix.php(24): CDbMigration->execute('UPDATE {{users}...')
#2 /Applications/MAMP/htdocs/yii-1.1.13.e9e4a0/framework/db/CDbMigration.php(50): m110810_162301_userTimestampFix->safeUp()
#3 /Applications/MAMP/htdocs/yii-1.1.13.e9e4a0/framework/cli/commands/MigrateCommand.php(385): CDbMigration->up()
#4 /Applications/MAMP/htdocs/yii-1.1.13.e9e4a0/framework/cli/commands/MigrateCommand.php(109): MigrateCommand->migrateUp('m110810_162301_...')
#5 [internal function]: MigrateCommand->actionUp(Array)
#6 /Applications/MAMP/htdocs/yii-1.1.13.e9e4a0/framework/console/CConsoleCommand.php(172): ReflectionMethod->invokeArgs(Object(MigrateCommand), Array)
#7 /Applications/MAMP/htdocs/yii-1.1.13.e9e4a0/framework/console/CConsoleCommandRunner.php(67): CConsoleCommand->run(Array)
#8 /Applications/MAMP/htdocs/yii-1.1.13.e9e4a0/framework/console/CConsoleApplication.php(91): CConsoleCommandRunner->run(Array)
#9 /Applications/MAMP/htdocs/yii-1.1.13.e9e4a0/framework/base/CApplication.php(169): CConsoleApplication->processRequest()
#10 /Applications/MAMP/htdocs/yii-1.1.13.e9e4a0/framework/yiic.php(33): CApplication->run()
#11 /Applications/MAMP/htdocs/yii1.1/protected/yiic.php(7): require_once('/Applications/M...')
#12 /Applications/MAMP/htdocs/yii1.1/protected/yiic(4): require_once('/Applications/M...')
#13 {main}

*** failed to apply m110810_162301_userTimestampFix (time: 0.323s)

Migration failed. All later migrations are canceled.

Somehow, I can't imagine that {{users}} {{profiles}} and {{profiles_fields}} are the correct table names...

Any ideas what went wrong??

Registration problem: file uploaded with UWfile widget not written to disk

In a profile made with the yii-user module, I added a file upload field that uses the UWfile widget. This field is set 'Required: No, but show on registration form'.

When a user registers an account and NOT upload a file, everything is ok. Also when the user logs in and then update the profile with a file upload, this works perfectly.

The problem is that when a 'guest' fills out the registration form and tries to upload a file, no error is given but the file is NOT written to disk (nowhere found on the system!).

Is this perhaps intended behaviour or is this a bug? Does anyone has a solution?

Greetings,
Ametad

bug recovery passord

On UserRecoveryForm.php model there is a bug.
regex do not accept email whit "" ex: [email protected]
I solved whit replace the regex with: /^[a-zA-Z0-9.
%+-]+@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,4}$/

error email verification

fix by add
public function updateSession() {
$user = Yii::app()->getModule('user')->user($this->id);

  •   if ($user == false) {return;}
    

Disable username, register and login only with email and password

Is there already such an option or what is a neat way to do this? There's no necessity to remove username completely, just disable it so it can be enabled later on.

Some steps I consider to be essential:

  1. Make field username in the users table NULL DEFAULT NULL.
  2. Remove username from the registration form and all associated validation.
  3. Change user model so it ignores username.

Migrate error.

A error after when i run the migrate
yiic migrate --migrationPath=user.migrations
Error: The migration directory does not exist: user.migrations

widgetAttributes() not found when opening profile

Hi, I have just installed yii-user, and when I tried to register a user (which would access profiles, I would have the an error stating that widgetAttributes() is not found.

This error is caught in UActiveRecord class specifically in the setAttributes() method.

Is this a bug or am I missing something?
For the time being I am checking whether that method is exist with method_exists function and than dismiss it if its not found. I know its a rough fix but so far its running good. Anyone know any what that code parts is doing?

To be clear, here is my modified method:

public function setAttributes($values, $safeOnly = true) {
    if(method_exists($this, "widgetAttribute"))
    {
        foreach ($this->widgetAttributes() as $fieldName => $className) {
            if (isset($values[$fieldName]) && class_exists($className)) {
                $class = new $className;
                $arr = $this->widgetParams($fieldName);
                if ($arr) {
                    $newParams = $class->params;
                    $arr = (array) CJavaScript::jsonDecode($arr);
                    foreach ($arr as $p => $v) {
                        if (isset($newParams[$p]))
                            $newParams[$p] = $v;
                    }
                    $class->params = $newParams;
                }
                if (method_exists($class, 'setAttributes')) {
                    $values[$fieldName] = $class->setAttributes($values[$fieldName], $this, $fieldName);
                }
            }
        }
    }
    parent::setAttributes($values, $safeOnly);
}

not creating tables - Users, Profiles, Profile_fields

Hi,

Thanks for this Awesome module.. I have installed yii-user module and also have done user migration but somehow after completing migration i coundn't see new tables in my database..

do you have any idea what could be the reason behind this?

Thanks,
MiteshSC

Mistype in UWrelBelongsTo.php

Hi!

line 74 in UWrelBelongsTo.php file reads:
return CHtml::activeDropDownList($model, $field->varname, $list, $htmlOptions=array());

I believe it should be:
return CHtml::activeDropDownList($model, $field->varname, $list, $htmlOptions);

rash*

login_or_email validatation pattern bug

yii-user/models/UserRecoveryForm.php

array('login_or_email', 'match', 'pattern' => '/^[[email protected]\s,]+$/u','message' => UserModule::t("Incorrect symbols (A-z0-9)."))

It didn't work properly. I tried to give it string "[email protected]" and it fails. I changed it to

array('login_or_email', 'match', 'pattern' => '/^[A-Za-z0-9@.\-\s,]+$/u','message' => UserModule::t("Incorrect symbols (A-z0-9).")),

However i'm not sure is it right, but now it passes validation

Update and Save + Password Validation fails

Change the password rules to a custom validator requiring a special character. Try to save. Password changing fails silently.

In between validate and save, it changes the password to the md5 string. When we change the password validator to a type that does not fit the md5 characteristics, this will cause the save to fail. Because the save isn't tested, the redirect statement is still executed, even though because we need to show the errors on the save form.

othervalidator field is text in database, but limits input to 255 via application.

I don't know whether this is intended or not, but since the database field is text (which allow more than 255 characters of input, I don't see why we should limit this via application.

I am bringing this up since I got the limit when I am using fileupload widget using all available validators and that exceeds 255 characters.

As for the moment, the fix is I disabled the length checking for othervalidator field in class ProfileField

User model defaultScope

I think User model deafultScope method should consider the module config array to override the default and one not the opposite

Something like this
public function defaultScope()
{
return CMap::mergeArray(array(
'alias'=>'user',
'select' => 'user.id, user.username, user.email, user.create_at, user.lastvisit_at, user.superuser, user.status',
), Yii::app()->getModule('user')->defaultScope);
}

RWebUser and its behaviors do not have a method or closure named "updateSession".

This is a great module in many ways, but every time I log out and log back in it produces the error message RWebUser and its behaviors do not have a method or closure named "updateSession". If I then hit the browser's back button, it returns me to the Web site, and I'm logged in just fine.

In the stack, this appears to originate in this call:

public function afterSave() {
         if (get_class(Yii::app())=='CWebApplication'&&Profile::$regMode==false) {
             Yii::app()->user->updateSession();
         }
         return parent::afterSave();
     }

found in protected\modules\user\models\User.php.

At this point, I've had to comment out all references to any relationship to the User model because of similar problems with RWebUser. Is there any resolution for this?

Integrate composer

Please integrate composer support so other plugins can depend on yii-user

Create tags for releases

Please add a tag to your repo, if you've a new release ready. It simplifies the usage with composer very much.

Like 0.4 for the next release, thank you!

Use instanceof!

In file yii-user/models/User.php, line number 51:

        return ((get_class(Yii::app())=='CConsoleApplication' || (get_class(Yii::app())!='CConsoleApplication' && Yii::app()->getModule('user')->isAdmin()))?array(

change to

        return ((Yii::app() instanceof CConsoleApplication || (!(Yii::app() instanceof CConsoleApplication) && Yii::app()->getModule('user')->isAdmin()))?array(

Password recovery and spam

Users should only be allowed to recover their password 3 times an hour at max to prevent spam. Now I can fill in any username or e-mail address and create an auto clicker, resulting in my target getting mail bombed.

File upload widget issue on Yii v1.1.12

Due to change in framework the file uploads but database is not updated .

fix: following value needs to be added to other validatiors - '{"file":"allowEmpty":"true","maxFiles":"1","types":"jpg,png,gif","safe":"true"}}' .

Note: "safe" is to be set with true.

session not update

Hi

I made all instruction steps except migration. When I login my session not update, because lastvisit time in table udated but I'm still not login. Is it posible because I did not made migration step?

Resend email verification on email change

It would be nice to have the option to resend the email verification code to the new email address somehow.

I think that an account email change system as github provides will be ideal !
To have the ability to add more email addresses and to have one primary.

updateSession() results in 'Trying to get property of non-object'

If the new User is NOT logged in after a registration, the calling of updateSession() in the User::afterSave() or Profile::afterSave() function will result in an error: 'Trying to get property of non-object'.

I think a check is in order to verify the current user is not a guest, before running updateSession.

invalid reference `lastvisit_at`

Just noticed while the mysql database scheme contains lastvisit column, all the references to this column are as lastvisit_at.

Changing the column name in database fixes the problem.

Russian translation

in /views/recovery/changepassword.php
used UserModule::t("Change Password"), but in /messages/ru/user.php there is "'Change password' => 'Изменить пароль'," case-sensitive string

Password recovery errors on submission of new password

What steps will reproduce the problem?

  1. Click "Lost Password?".
  2. Enter user name, click Recovery, get email.
  3. Enter link from email.
  4. Enter new password (twice), click Save.

Error (attached) is presented and page fails to load.
Tried entering the activation link again and you get the message "Incorrect recovery link."

Password appears to have been changed.

Latest source from github at the time or reporting.

submit-password-recovery

Unable to install application

HI All,

I am new for the Yii2.
I follow the instruction given in the installment process but unable to execute it.
Can anybody explain how can i install it on my local system?

Thanks in advance.

Change upload path when using Widget File Field still leads to 'assets'

I change upload path from widget parameters into 'images', but it still using 'assets' as upload path.

i modified components/UWfile.php line 60 to this, and it does the job.
[code]
if ($this->_new_file_path){
$this->_new_file_path .= $this->unique_dir($this->_new_file_path).'/';
} else {
$this->_new_file_path = pathinfo($this->_old_file_path, PATHINFO_DIRNAME).'/';
}
[/code]
Sorry, I'm still new to this git hub thingie

Trying to get property of non-object.

Hi.
I've just installed yii-eauth extension and the authentication process works pretty well, but after auth I get this error. Any suggestions?

I was thinking about storing service->id as user's ID in my database just after successful login.

I'm using Yii 1.1.12 with yii-user module and this is the errors:

in pop-up window:
protected\components\WebUser.php(39):

36 public function updateSession() {
37         $user = Yii::app()->getModule('user')->user($this->id);
38         $userAttributes = CMap::mergeArray(array(
39                                                 'email'=>$user->email,
40                                                 'username'=>$user->username,
41                                                 'create_at'=>$user->create_at,
42                                                 'lastvisit_at'=>$user->lastvisit_at,
43                                            ),$user->profile->getAttributes());
44         foreach ($userAttributes as $attrName=>$attrValue) {
45             $this->setState($attrName,$attrValue);
46         }
47     }

in any other site:
protected\modules\user\UserModule.php(197)

public static function isAdmin() {
193         if(Yii::app()->user->isGuest)
194             return false;
195         else {
196             if (!isset(self::$_admin)) {
197                 if(self::user()->superuser)
198                     self::$_admin = true;
199                 else
200                     self::$_admin = false;
201             }
202             return self::$_admin;
203         }
204     }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.