This commit is contained in:
LAPTOP-DGCU80CH\user1
2020-12-07 15:42:04 +08:00
parent a5e74cd774
commit 60231e9062
3 changed files with 63 additions and 62 deletions
+28 -33
View File
@@ -151,12 +151,12 @@ class CustomersController extends Controller
}
public function getOTP(Request $request){
$auth_user = Auth::user();
$expired = Carbon::now();
$expired = new Carbon();
$expired = $expired->addHours(24);
$nokp = $request->noic_otp;
$nokp = $request->noic;
//pembinaan token
function token($length) {
@@ -170,39 +170,34 @@ class CustomersController extends Controller
shuffle($characters);
return implode("", array_slice($characters, 0, $length));
}
$random = token(6);
// dd($expired);
$otp_baru = Http::post(config('url.api') . '/api/otp/generateotp/' . $nokp,[
'otptoken' => $random,
'expired' => $expired,
]);
// dd($otp_baru);
return redirect()->route('customer_info');
// $otp_token = Http::get(config('api.url') . '/api/otp/' . $nokp) ->json();
// // dd($nokp);
// if (is_array($otp_token) || is_object($otp_token)){
// if($otp_token){
// return redirect()->route('customer_info');
// }else{
// $random = token(6);
// $otp_baru = Http::post(config('url.api'). '/api/otp/create/' . $nokp,[
// 'otptoken' => $random,
// 'expired' => $expired
// ]);
// return redirect()->route('customer_info');
// }
// }else{
// $random = token(6);
// $otp_baru = Http::post(config('url.api'). '/api/otp/create/' . $nokp,[
// 'otptoken' => $random,
// 'expired' => $expired
// ]);
$otp_token = Http::get(config('api.url') . '/api/otp/' . $nokp) ->json();
// return redirect()->route('customer_info');
// }
if (is_array($otp_token) || is_object($otp_token)){
if($otp_token){
return response(['error' => "OTP Akaun Telah Di Jana"]);
}else{
$random = token(6);
$otp_baru = Http::post(config('api.url'). '/api/otp/generateotp/' . $nokp,[
'otptoken' => $random,
'expired' => $expired,
'kodcaw' => $auth_user['cawangan']
]);
return response()->json(['otp'=>$random]);
}
}else{
$random = token(6);
$otp_baru = Http::post(config('api.url'). '/api/otp/generateotp/' . $nokp,[
'otptoken' => $random,
'expired' => $expired,
'kodcaw' => $auth_user['cawangan']
]);
return response()->json(['otp'=>$random]);
}
}
}