|
|
@@ -7,6 +7,7 @@ use App\Models\User; |
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
use Illuminate\Support\Facades\Hash; |
|
|
|
use Illuminate\Auth\Events\Registered; |
|
|
|
use Illuminate\Support\Facades\Password; |
|
|
|
|
|
|
|
class UserController extends Controller |
|
|
|
{ |
|
|
@@ -21,6 +22,7 @@ class UserController extends Controller |
|
|
|
$user = new User; |
|
|
|
$user->name = $request->name; |
|
|
|
$user->email = $request->email; |
|
|
|
$user->role = "client"; |
|
|
|
$user->password = Hash::make($request->password); |
|
|
|
$user->save(); |
|
|
|
|
|
|
@@ -29,4 +31,45 @@ class UserController extends Controller |
|
|
|
"status" => "success" |
|
|
|
]); |
|
|
|
} |
|
|
|
|
|
|
|
public function forgotPassword(Request $request) { |
|
|
|
$request->validate(['email' => 'required|email']); |
|
|
|
|
|
|
|
$status = Password::sendResetLink( |
|
|
|
$request->only('email') |
|
|
|
); |
|
|
|
|
|
|
|
if ($status === Password::RESET_LINK_SENT) { |
|
|
|
return response()->json([ |
|
|
|
"status" => "success" |
|
|
|
]) |
|
|
|
} else { |
|
|
|
return response()->json($errors->all()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function resetPassword(Request $request) { |
|
|
|
|
|
|
|
$request->validate([ |
|
|
|
'token' => 'required', |
|
|
|
'email' => 'required|email', |
|
|
|
'password' => 'required|min:8|confirmed', |
|
|
|
]); |
|
|
|
|
|
|
|
$status = Password::reset( |
|
|
|
$request->only('email', 'password', |
|
|
|
'password_confirmation', 'token'), |
|
|
|
function ($user, $password) use ($request) { |
|
|
|
$user->forceFill([ |
|
|
|
'password' => Hash::make($password) |
|
|
|
])->setRememberToken(Str::random(60)) |
|
|
|
}); |
|
|
|
if ($status == Password::PASSWORD_RESET) { |
|
|
|
return response()->json([ |
|
|
|
"status" => "success" |
|
|
|
]); |
|
|
|
} else { |
|
|
|
return response()->json([__($status)]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |