diff --git a/controllers/UserController.php b/controllers/UserController.php index 150a2a7..4fc9e0e 100644 --- a/controllers/UserController.php +++ b/controllers/UserController.php @@ -302,6 +302,7 @@ class UserController extends Controller $model->auth_key = Yii::$app->security->generateRandomString(); $model->created_at = date('Y-m-d H:i:s'); $model->role = 'user'; + $model->name = $model->username; //用户默认昵称为用户名,后期可以修改 if ($model->save(false)) { // save without validation Yii::$app->session->setFlash('success', 'Registration successful. You can now log in.'); return $this->redirect(['login']); @@ -334,7 +335,12 @@ class UserController extends Controller $usedSpace = FileSizeHelper::getDirectorySize($dataDirectory); $vaultUsedSpace = 0; // 保险箱已用空间,暂时为0 $storageLimit = $model->storage_limit; - + if (Yii::$app->request->isPost && $model->load(Yii::$app->request->post())) { + if($model->save()){ + Yii::$app->session->setFlash('success', '个人简介已更新'); + return $this->refresh(); + } + } return $this->render('info', [ 'model' => $model, 'usedSpace' => $usedSpace, // B diff --git a/models/User.php b/models/User.php index 817db76..2a8065a 100644 --- a/models/User.php +++ b/models/User.php @@ -12,6 +12,7 @@ use yii\web\IdentityInterface; * * @property int $id 用户ID * @property string|null $username 用户名 + * @property string|null $name 昵称 * @property string|null $password 密码 * @property string|null $auth_key authkey * @property string|null $email 邮箱 @@ -57,7 +58,7 @@ class User extends ActiveRecord implements IdentityInterface [['username', 'password'], 'required', 'on' => 'login'], [['username', 'password', 'email', 'password2'], 'required', 'on' => 'register'], ['username', 'string', 'min' => 3, 'max' => 12], - ['password', 'string', 'min' => 6, 'max' => 24], + ['password', 'string', 'min' => 6, 'max' => 24, 'on' => 'register'], ['password2', 'compare', 'compareAttribute' => 'password', 'on' => 'register'], ['email', 'email', 'on' => 'register'], ['username', 'unique', 'on' => 'register'], @@ -73,6 +74,7 @@ class User extends ActiveRecord implements IdentityInterface return [ 'id' => 'ID', 'username' => 'Username', + 'name' => 'Name', 'password' => 'Password', 'auth_key' => 'Auth Key', 'email' => 'Email', diff --git a/views/user/info.php b/views/user/info.php index fdec04b..bd83c76 100644 --- a/views/user/info.php +++ b/views/user/info.php @@ -114,16 +114,17 @@ $totalUsedPercent = min(($usedPercent + $vaultUsedPercent), 100); //总已用百
网盘已用空间 - + + ', ['home/index']) ?> +
保险箱已用空间 - + + + ', ['site/index']) ?> +
@@ -142,7 +143,12 @@ $totalUsedPercent = min(($usedPercent + $vaultUsedPercent), 100); //总已用百
- + + field($model, 'bio')->textarea(['rows' => 6])->label('简介') ?> +
+ 'btn btn-success']) ?> +
+