Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function changePassword()
- {
- try {
- $user = User::findOrFail(request()->input('id'));
- if (Hash::check(request()->input('password'), $user->password)) {
- throw ValidationException::withMessages([
- 'password' => ['translation.newPasswordMustBeDifferent']
- ]);
- }
- request()->validate([
- 'password' => 'required|string|min:6',
- ]);
- $user->password = bcrypt(request()->input('password'));
- $user->save();
- return response()->json([
- 'status' => 1,
- 'message' => 'success',
- ]);
- } catch (ValidationException $ex) {
- return response()->json([
- 'status' => 0,
- 'message' => 'error',
- 'error' => $ex->errors(),
- ], 422);
- } catch (\Exception $ex) {
- return response()->json([
- 'status' => 0,
- 'message' => 'error',
- 'error' => $ex->getMessage(),
- ], 500);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement