|
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers; |
|
|
|
use App\Services\AuditLogService; |
|
|
|
use App\Services\AuditLogService; |
|
|
|
use App\Services\LdapAuthService; |
|
|
|
use App\Services\LdapAuthService; |
|
|
|
use App\Services\LdapPasswordResetService; |
|
|
|
use App\Services\LdapPasswordResetService; |
|
|
|
|
|
|
|
use Illuminate\Http\JsonResponse; |
|
|
|
use Illuminate\Http\RedirectResponse; |
|
|
|
use Illuminate\Http\RedirectResponse; |
|
|
|
use Illuminate\Http\Request; |
|
|
|
use Illuminate\Http\Request; |
|
|
|
use Illuminate\View\View; |
|
|
|
use Illuminate\View\View; |
|
|
|
@ -100,6 +101,28 @@ class AuthController extends Controller |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function apiForgotPassword(Request $request): JsonResponse |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$data = $request->validate([ |
|
|
|
|
|
|
|
'username' => ['required', 'string', 'max:100', 'regex:/^[a-zA-Z0-9._-]+$/'], |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
$this->passwordReset->sendResetLink($data['username']); |
|
|
|
|
|
|
|
$this->audit->logPublic('auth.password.forgot', $data['username'], $request, [ |
|
|
|
|
|
|
|
'username' => $data['username'], |
|
|
|
|
|
|
|
'source' => 'api', |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
} catch (\Throwable) { |
|
|
|
|
|
|
|
// Do not reveal whether user exists or email failed. |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response()->json([ |
|
|
|
|
|
|
|
'data' => ['message' => 'Jika akun ditemukan dan memiliki email terdaftar, link reset password telah dikirim.'], |
|
|
|
|
|
|
|
'error' => null, |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function showResetPassword(string $token): View|RedirectResponse |
|
|
|
public function showResetPassword(string $token): View|RedirectResponse |
|
|
|
{ |
|
|
|
{ |
|
|
|
$username = $this->passwordReset->validateToken($token); |
|
|
|
$username = $this->passwordReset->validateToken($token); |
|
|
|
|