/home/kueuepay/public_html/app/Http/Controllers/Admin/AuthorizationController.php
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class AuthorizationController extends Controller
{
    public function showGoogle2FAForm()
    {
        $page_title =  __("admin.page.google.2fa.verification");
        return view('admin.auth.authorize.verify-google-2fa',compact('page_title'));
    }


    public function google2FASubmit(Request $request) {

        $request->validate([
            'code'    => "required|string",
        ]);
        $code = $request->code;

        $user = auth()->user();

        if(!$user->two_factor_secret) {
            return back()->with(['warning' => [__("Your secret key not stored properly. Please contact with system administrator")]]);
        }

        if(google_2fa_verify($user->two_factor_secret,$code)) {
            $user->update([
                'two_factor_verified'   => true,
            ]);
            return redirect()->intended(route('admin.dashboard'));
        }

        return back()->with(['error' => [__("Invalid code. Please try again")]]);
    }
}
Best Practice

Best Practices

To ensure a smooth integration process and optimal performance, follow these best practices:

  1. Use secure HTTPS connections for all API requests.
  2. Implement robust error handling to handle potential issues gracefully.
  3. Regularly update your integration to stay current with any API changes or enhancements.