Fix OTP
This commit is contained in:
@@ -71,30 +71,26 @@ class AuthController extends Controller
|
||||
'otp' => 'required'
|
||||
]);
|
||||
|
||||
$loginType = null;
|
||||
$loginType = filter_var($request->phone_or_email, FILTER_VALIDATE_EMAIL) ? 'email' : 'phone';
|
||||
|
||||
if ($request->has('password') && !empty($request->password)) {
|
||||
if ($loginType == 'email') {
|
||||
$user = User::query()
|
||||
->where('email', $request->phone_or_email)
|
||||
->first();
|
||||
|
||||
$loginType = 'email';
|
||||
}
|
||||
|
||||
if ($request->has('otp') && !empty($request->otp)) {
|
||||
if ($loginType == 'phone') {
|
||||
$user = User::query()
|
||||
->where('phone', $request->phone_or_email)
|
||||
->first();
|
||||
|
||||
$loginType = 'phone';
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
if (!isset($user) || empty($user)) {
|
||||
return response(['message' => 'User Tidak Ditemukan'], 404);
|
||||
}
|
||||
|
||||
if ($loginType == 'email') {
|
||||
if (!Hash::check($request->password, $user->password)) {
|
||||
if ($request->otp != $user->otp) {
|
||||
return response(['message' => 'OTP Salah, Silahkan Cek Kembali Email Anda'], 403);
|
||||
}
|
||||
} else if ($loginType == 'phone') {
|
||||
|
||||
Reference in New Issue
Block a user