mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-26 02:04:52 +01:00
Update User controller
This commit is contained in:
parent
c044dcd6c6
commit
7ded76c92e
@ -85,7 +85,7 @@ public function register(Request $request)
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|confirmed',
|
||||
'password' => 'required|confirmed|min:8',
|
||||
]);
|
||||
|
||||
$input = $request->all();
|
||||
@ -107,4 +107,41 @@ public function getDetails()
|
||||
{
|
||||
return response()->json(Auth::user(), 200);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the user's profile information.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email|unique:users,email,'.$user->id,
|
||||
]);
|
||||
|
||||
return tap($user)->update($request->only('name', 'email'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the user's password.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function changePassword(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'password' => 'required|confirmed|min:8',
|
||||
]);
|
||||
|
||||
$request->user()->update([
|
||||
'password' => bcrypt($request->password),
|
||||
]);
|
||||
}
|
||||
}
|
@ -27,7 +27,10 @@
|
||||
Route::group(['middleware' => 'auth:api'], function() {
|
||||
|
||||
Route::post('logout', 'UserController@logout');
|
||||
Route::patch('user/edit', 'UserController@update');
|
||||
Route::patch('user/password', 'UserController@changePassword');
|
||||
Route::get('user', 'UserController@getDetails');
|
||||
|
||||
Route::apiResource('twofaccounts', 'TwoFAccountController');
|
||||
Route::get('twofaccounts/{twofaccount}/totp', 'TwoFAccountController@generateTOTP')->name('twofaccounts.generateTOTP');
|
||||
Route::post('qrcode/decode', 'QrCodeController@decode');
|
||||
|
Loading…
Reference in New Issue
Block a user