当我注册一个新的用户注册时,它用散列密码将密码保存到数据库中。但是当我从管理 Jmeter 板编辑用户时,编辑功能工作得很好,但是密码没有存储或保存为散列密码,而是保存为纯文本。
这是在数据库修改中显示图像的链接
这就是 userController
:
public function edit($id)
{
$user = $this->userRepository->find($id);
if (empty($user)) {
Flash::error('User not found');
return redirect(route('users.index'));
}
return view('users.edit')->with('user', $user);
}
/**
* Update the specified User in storage.
*
* @param int $id
* @param UpdateUserRequest $request
*
* @return Response
*/
public function update($id, UpdateUserRequest $request)
{
$user = $this->userRepository->find($id);
if (empty($user)) {
Flash::error('User not found');
return redirect(route('users.index'));
}
$user = $this->userRepository->update($request->all(), $id);
Flash::success('User updated successfully.');
return redirect(route('users.index'));
}
这是我的 fields.blade.php
:
<!-- Name Field -->
<div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!}
{!! Form::text('name', null, ['class' => 'form-control']) !!}
</div>
<!-- Email Field -->
<div class="form-group col-sm-6">
{!! Form::label('email', 'Email:') !!}
{!! Form::email('email', null, ['class' => 'form-control']) !!}
</div>
@push('scripts')
<script type="text/javascript">
$('#email_verified_at').datetimepicker({
format: 'YYYY-MM-DD HH:mm:ss',
useCurrent: true,
sideBySide: true
})
</script>
@endpush
<!-- Password Field -->
<div class="form-group col-sm-6">
{!! Form::label('password', 'Password:') !!}
{!! Form::password('password', ['class' => 'form-control']) !!}
</div>
<!-- Role Id Field -->
<div class="form-group col-sm-6">
{!! Form::label('role_id', 'Role Id:') !!}
{!! Form::number('role_id', null, ['class' => 'form-control']) !!}
</div>
<!-- Submit Field -->
<div class="form-group col-sm-12">
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}
<a href="{{ route('users.index') }}" class="btn btn-default">Cancel</a>
</div>
另一件事:我正在使用 infyom
雷达波发生器。
这是寄存器控制器(我通过命令 make:auth
):
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
这就是 userRepository
代码:
<?php
namespace App\Repositories;
use App\Models\User;
use App\Repositories\BaseRepository;
/**
* Class UserRepository
* @package App\Repositories
* @version June 23, 2020, 3:11 pm UTC
*/
class UserRepository extends BaseRepository
{
/**
* @var array
*/
protected $fieldSearchable = [
'name',
'email',
'password',
'role_id'
];
/**
* Return searchable fields
*
* @return array
*/
public function getFieldsSearchable()
{
return $this->fieldSearchable;
}
/**
* Configure the Model
**/
public function model()
{
return User::class;
}
}
1条答案
按热度按时间2guxujil1#
将update方法添加到userrepository