Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now the user name can be the email #9

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controllers/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ private function lastViset() {
$lastVisit->save();
}

}
}
2 changes: 1 addition & 1 deletion data/schema.mysql.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CREATE TABLE `tbl_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(20) NOT NULL,
`username` varchar(128) NOT NULL,
`password` varchar(128) NOT NULL,
`email` varchar(128) NOT NULL,
`activkey` varchar(128) NOT NULL DEFAULT '',
Expand Down
4 changes: 2 additions & 2 deletions models/RegistrationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ class RegistrationForm extends User {
public function rules() {
$rules = array(
array('username, password, verifyPassword, email', 'required'),
array('username', 'length', 'max'=>20, 'min' => 3,'message' => UserModule::t("Incorrect username (length between 3 and 20 characters).")),
array('username', 'length', 'max'=>128, 'min' => 3,'message' => UserModule::t("Incorrect username (length between 3 and 128 characters).")),
array('password', 'length', 'max'=>128, 'min' => 4,'message' => UserModule::t("Incorrect password (minimal length 4 symbols).")),
array('email', 'email'),
array('username', 'unique', 'message' => UserModule::t("This user's name already exists.")),
array('email', 'unique', 'message' => UserModule::t("This user's email address already exists.")),
//array('verifyPassword', 'compare', 'compareAttribute'=>'password', 'message' => UserModule::t("Retype Password is incorrect.")),
array('username', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u','message' => UserModule::t("Incorrect symbols (A-z0-9).")),
array('username', 'match', 'pattern' => '/^[A-Za-z0-9_@.]+$/u','message' => UserModule::t("Incorrect symbols (A-z0-9@).")),
);
if (!(isset($_POST['ajax']) && $_POST['ajax']==='registration-form')) {
array_push($rules,array('verifyCode', 'captcha', 'allowEmpty'=>!UserModule::doCaptcha('registration')));
Expand Down
14 changes: 5 additions & 9 deletions models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class User extends CActiveRecord
* @var string $password
* @var string $email
* @var string $activkey
* @var integer $createtime
* @var integer $lastvisit
* @var integer $superuser
* @var integer $status
* @var timestamp $create_at
Expand Down Expand Up @@ -49,12 +47,12 @@ public function rules()
// NOTE: you should only define rules for those attributes that
// will receive user inputs.CConsoleApplication
return ((get_class(Yii::app())=='CConsoleApplication' || (get_class(Yii::app())!='CConsoleApplication' && Yii::app()->getModule('user')->isAdmin()))?array(
array('username', 'length', 'max'=>20, 'min' => 3,'message' => UserModule::t("Incorrect username (length between 3 and 20 characters).")),
array('username', 'length', 'max'=>128, 'min' => 3,'message' => UserModule::t("Incorrect username (length between 3 and 128 characters).")),
array('password', 'length', 'max'=>128, 'min' => 4,'message' => UserModule::t("Incorrect password (minimal length 4 symbols).")),
array('email', 'email'),
array('username', 'unique', 'message' => UserModule::t("This user's name already exists.")),
array('email', 'unique', 'message' => UserModule::t("This user's email address already exists.")),
array('username', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u','message' => UserModule::t("Incorrect symbols (A-z0-9).")),
array('username', 'match', 'pattern' => '/^[A-Za-z0-9_@.]+$/u','message' => UserModule::t("Incorrect symbols (A-z@0-9).")),
array('status', 'in', 'range'=>array(self::STATUS_NOACTIVE,self::STATUS_ACTIVE,self::STATUS_BANNED)),
array('superuser', 'in', 'range'=>array(0,1)),
array('create_at', 'default', 'value' => date('Y-m-d H:i:s'), 'setOnEmpty' => true, 'on' => 'insert'),
Expand All @@ -64,10 +62,10 @@ public function rules()
array('id, username, password, email, activkey, create_at, lastvisit_at, superuser, status', 'safe', 'on'=>'search'),
):((Yii::app()->user->id==$this->id)?array(
array('username, email', 'required'),
array('username', 'length', 'max'=>20, 'min' => 3,'message' => UserModule::t("Incorrect username (length between 3 and 20 characters).")),
array('username', 'length', 'max'=>128, 'min' => 3,'message' => UserModule::t("Incorrect username (length between 3 and 128 characters).")),
array('email', 'email'),
array('username', 'unique', 'message' => UserModule::t("This user's name already exists.")),
array('username', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u','message' => UserModule::t("Incorrect symbols (A-z0-9).")),
array('username', 'match', 'pattern' => '/^[A-Za-z0-9_@.]+$/u','message' => UserModule::t("Incorrect symbols (A-[email protected]-9).")),
array('email', 'unique', 'message' => UserModule::t("This user's email address already exists.")),
):array()));
}
Expand Down Expand Up @@ -96,9 +94,7 @@ public function attributeLabels()
'email'=>UserModule::t("E-mail"),
'verifyCode'=>UserModule::t("Verification Code"),
'activkey' => UserModule::t("activation key"),
'createtime' => UserModule::t("Registration date"),
'create_at' => UserModule::t("Registration date"),

'lastvisit_at' => UserModule::t("Last visit"),
'superuser' => UserModule::t("Superuser"),
'status' => UserModule::t("Status"),
Expand Down Expand Up @@ -196,4 +192,4 @@ public function getLastvisit() {
public function setLastvisit($value) {
$this->lastvisit_at=date('Y-m-d H:i:s',$value);
}
}
}
6 changes: 4 additions & 2 deletions views/profile/changepassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
((UserModule::isAdmin())
?array('label'=>UserModule::t('Manage Users'), 'url'=>array('/user/admin'))
:array()),
array('label'=>UserModule::t('List User'), 'url'=>array('/user')),
((UserModule::isAdmin())
? array('label'=>UserModule::t('List User'), 'url'=>array('/user'))
:array()),
array('label'=>UserModule::t('Profile'), 'url'=>array('/user/profile')),
array('label'=>UserModule::t('Edit'), 'url'=>array('edit')),
array('label'=>UserModule::t('Logout'), 'url'=>array('/user/logout')),
Expand Down Expand Up @@ -55,4 +57,4 @@
</div>

<?php $this->endWidget(); ?>
</div><!-- form -->
</div><!-- form -->
4 changes: 3 additions & 1 deletion views/profile/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
((UserModule::isAdmin())
?array('label'=>UserModule::t('Manage Users'), 'url'=>array('/user/admin'))
:array()),
array('label'=>UserModule::t('List User'), 'url'=>array('/user')),
((UserModule::isAdmin())
? array('label'=>UserModule::t('List User'), 'url'=>array('/user'))
:array()),
array('label'=>UserModule::t('Profile'), 'url'=>array('/user/profile')),
array('label'=>UserModule::t('Change password'), 'url'=>array('changepassword')),
array('label'=>UserModule::t('Logout'), 'url'=>array('/user/logout')),
Expand Down
4 changes: 3 additions & 1 deletion views/profile/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
((UserModule::isAdmin())
?array('label'=>UserModule::t('Manage Users'), 'url'=>array('/user/admin'))
:array()),
array('label'=>UserModule::t('List User'), 'url'=>array('/user')),
((UserModule::isAdmin())
? array('label'=>UserModule::t('List User'), 'url'=>array('/user'))
:array()),
array('label'=>UserModule::t('Edit'), 'url'=>array('edit')),
array('label'=>UserModule::t('Change password'), 'url'=>array('changepassword')),
array('label'=>UserModule::t('Logout'), 'url'=>array('/user/logout')),
Expand Down