This commit is contained in:
LAPTOP-DGCU80CH\user1
2020-12-07 14:54:54 +08:00
parent 378b0f19a2
commit 2016959518
3 changed files with 74 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace App\Http\Controllers;
use App\OtpToken;
use Illuminate\Http\Request;
use Carbon\Carbon;
class OtpController extends Controller
{
public function createOtp($nokp,Request $request){
$otp = OtpToken::on('mysql7')->create([
'nokp' => $nokp,
'expired' => $request->expired,
'token' => $request->otptoken,
'used'=> 0
]);
return response()->json($otp, 201);
}
public function getOtp($nokp){
$current = Carbon::now();
$current = new Carbon();
$otp = OtpToken::on('mysql7')->where([['nokp','=',$nokp],['used','=',0],['expired','>=',$current]])->get();
return response()->json($otp);
}
public function checkToken($otp_token){
$current = Carbon::now();
$current = new Carbon();
$otp = OtpToken::on('mysql7')->where([['token','=',$otp_token],['used','=',0],['expired','>=',$current]])->get();
return response()->json($otp);
}
}