0 レビュー
1 回答
laravel-有効なSMSコードが入力されるのを待ちます。それを確認した後、データをデータベースに保存php
こんにちは私はここで私のコードにいくつかの問題があります ユーザーがSMSコードを入力した後、データベースにデータを保存したいのですが、携帯電話に送信されます
ここでプロセスを待ち、データを保存したいのですが、失いたくないです
ユーザーがSMSコードを入力した後、すべてのデータをデータベースに保存します
public function registered(IdentityRequest $request) {
$response = Http::get(route('fake') , [
'national_id' => $request->input('national_id'),
'date_birth' => $request->input('date_birth')
]);
if($response['status'] == 200) {
// i saved the data here
$userInformation = $response['data'];
} else {
return $this->returnErrorResponse('E002', 'no user ', '404');
}
// send OTP verification after validate request of user
$otp = new Client(env('ENV_ACCOUNT_SID' , 'sid') , env('ENV_AUTH_TOKEN' , 'token));
$smsCode = rand(100000, 999999);
$message = $otp->messages->create("+".$request->input('phone') , [
"body" => $smsCode, // this code i send to user
"from" => "+11111"
]);
// here i want to whit untill user enter the code and i don't want to lose data
// from $request and $userInformation
// how i can do that
// after the user enter valid code sms and i check it from him
// i saved all the data in database
}
public function registered(IdentityRequest $request) {
$response = Http::get(route('fake') , [
'national_id' => $request->input('national_id'),
'date_birth' => $request->input('date_birth')
]);
if($response['status'] == 200) {
// i saved the data here
$userInformation = $response['data'];
} else {
return $this->returnErrorResponse('E002', 'no user ', '404');
}
// send OTP verification after validate request of user
$otp = new Client(env('ENV_ACCOUNT_SID' , 'sid') , env('ENV_AUTH_TOKEN' , 'token));
$smsCode = rand(100000, 999999);
$message = $otp->messages->create("+".$request->input('phone') , [
"body" => $smsCode, // this code i send to user
"from" => "+11111"
]);
// here i want to whit untill user enter the code and i don't want to lose data
// from $request and $userInformation
// how i can do that
// after the user enter valid code sms and i check it from him
// i saved all the data in database
}
わからない
0
レビュー
答え :
解決策:
それはできませんでした。
2フェーズと4ステップで行う必要があります
- ユーザーから情報を取得し、ファイルやデータベースなどの永続ストレージに保存します
- SMSを介してコードを送信し、ユーザー情報とともにコードを保存します
- SMSを送信し、ユーザーを別のページにリダイレクトします。そのため、ユーザーはフォームにメールまたはnational_idと送信したコードを入力する必要があります
- コードがユーザー情報と一致していることを確認します
わからない
同様の質問
私たちのウェブサイトで同様の質問で答えを見つけてください。