Skip to content

Commit ac9d8b9

Browse files
committed
Merge branch 'master' of github.com:windhoney/yii2-rest-rbac
2 parents b2d4ae8 + 7dab224 commit ac9d8b9

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Windhoney
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

controllers/UserController.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,19 @@ public function actionIndex()
4545
*/
4646
public function actionView($id)
4747
{
48-
$result = $this->findModel($id);
48+
$select = [
49+
"id",
50+
"username",
51+
"realname",
52+
"email",
53+
"status",
54+
"created_at",
55+
"updated_at"
56+
];
57+
$result = $this->findModel($id, $select);
4958
$result->created_at = date('Y年m月d日', $result->created_at);
50-
unset($result->password_hash);
51-
unset($result->auth_key);
52-
unset($result->password_reset_token);
53-
unset($result->dingId);
54-
59+
$result->updated_at = date('Y年m月d日', $result->updated_at);
60+
5561
return $result;
5662
}
5763

@@ -224,9 +230,9 @@ public function actionActivate($id)
224230
* @return User the loaded model
225231
* @throws NotFoundHttpException if the model cannot be found
226232
*/
227-
protected function findModel($id)
233+
protected function findModel($id, $select = ['*'])
228234
{
229-
if (($model = User::findOne($id)) !== null) {
235+
if (($model = User::find()->andWhere(['id' => $id])->select($select)->one()) !== null) {
230236
return $model;
231237
} else {
232238
return false;

0 commit comments

Comments
 (0)