2020-03-03 22:09:06 +01:00
|
|
|
<?php
|
|
|
|
|
2020-03-09 20:24:25 +01:00
|
|
|
namespace App\Http\Controllers\Settings;
|
2020-03-03 22:09:06 +01:00
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
|
|
|
|
class PasswordController extends Controller
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the user's password.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function update(Request $request)
|
|
|
|
{
|
|
|
|
$this->validate($request, [
|
|
|
|
'currentPassword' => 'required',
|
|
|
|
'password' => 'required|confirmed|min:8',
|
|
|
|
]);
|
|
|
|
|
|
|
|
if (!Hash::check( $request->currentPassword, Auth::user()->password) ) {
|
|
|
|
return response()->json(['message' => __('errors.wrong_current_password')], 400);
|
|
|
|
}
|
|
|
|
|
2020-03-18 22:59:45 +01:00
|
|
|
if (!config('app.options.isDemoApp') ) {
|
|
|
|
$request->user()->update([
|
|
|
|
'password' => bcrypt($request->password),
|
|
|
|
]);
|
|
|
|
}
|
2020-03-03 22:09:06 +01:00
|
|
|
|
|
|
|
return response()->json(['message' => __('auth.forms.password_successfully_changed')]);
|
|
|
|
}
|
|
|
|
}
|