From a5e74cd77447b5bdfc11c44f1b317131aa028f9c Mon Sep 17 00:00:00 2001 From: "LAPTOP-DGCU80CH\\user1" Date: Mon, 7 Dec 2020 14:54:02 +0800 Subject: [PATCH] otp --- app/Http/Controllers/CustomersController.php | 60 +++- resources/views/customers/index.blade.php | 3 - resources/views/customers/info.blade.php | 283 ++++++++++++------- resources/views/gadaian/index.blade.php | 2 - resources/views/layouts/app.blade.php | 2 +- routes/web.php | 2 +- 6 files changed, 235 insertions(+), 117 deletions(-) diff --git a/app/Http/Controllers/CustomersController.php b/app/Http/Controllers/CustomersController.php index 02f0282..ff46be5 100644 --- a/app/Http/Controllers/CustomersController.php +++ b/app/Http/Controllers/CustomersController.php @@ -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'); + // } } } diff --git a/resources/views/customers/index.blade.php b/resources/views/customers/index.blade.php index 849dbcf..fda97c1 100644 --- a/resources/views/customers/index.blade.php +++ b/resources/views/customers/index.blade.php @@ -25,9 +25,6 @@ - - @if($search == true ) diff --git a/resources/views/customers/info.blade.php b/resources/views/customers/info.blade.php index ba585bf..94b9ddb 100644 --- a/resources/views/customers/info.blade.php +++ b/resources/views/customers/info.blade.php @@ -1,117 +1,163 @@ @extends('layouts.app') -