Skip to content

Commit a4f2335

Browse files
committed
fix(control): 加密字段
1 parent 34bf7d7 commit a4f2335

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

laravel/app/Http/Controllers/Api/UserController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function store(Store $request)
6565
if (empty($input['email'])) {
6666
$input['email'] = $this->getEmail();
6767
}
68+
$input['password'] = bcrypt($input['password']);
6869
$model = new User($input);
6970
if ($model->save()) {
7071

@@ -127,6 +128,8 @@ public function update(Update $request, $id)
127128
$input = $request->only(['name', 'email', 'password']); // 获取 name, email 和 password 字段
128129
if (empty($input['password'])) {
129130
unset($input['password']);
131+
} else {
132+
$input['password'] = bcrypt($input['password']);
130133
}
131134
$roles = $request['checkedRoles']; // 获取所有角色
132135

0 commit comments

Comments
 (0)