This commit is contained in:
LAPTOP-DGCU80CH\user1
2020-12-07 14:54:02 +08:00
parent 0561535fb3
commit a5e74cd774
6 changed files with 235 additions and 117 deletions
+54 -6
View File
@@ -12,6 +12,8 @@ use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Auth;
use Carbon\Carbon;
class CustomersController extends Controller
{
private $customer_ic;
@@ -148,13 +150,59 @@ class CustomersController extends Controller
//
}
public function getOTP()
{
$auth_user = Auth::user();
$api_url = config('api.url');
$cawangan_info = Http::get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
public function getOTP(Request $request){
return view('onetimepassword.home',compact('cawangan_info','api_url'));
$expired = Carbon::now();
$expired = new Carbon();
$expired = $expired->addHours(24);
$nokp = $request->noic_otp;
//pembinaan token
function token($length) {
$characters = array(
"A","B","C","D","E","F","G","H","J","K","L","M",
"N","P","Q","R","S","T","U","V","W","X","Y","Z",
"a","b","c","d","e","f","g","h","i","j","k","m",
"n","o","p","q","r","s","t","u","v","w","x","y","z",
"1","2","3","4","5","6","7","8","9");
if ($length < 0 || $length > count($characters)) return null;
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
// ]);
// return redirect()->route('customer_info');
// }
}
}