芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/myvyralapp.com/bck/app/Http/Controllers/Api/Merchant/SecurityController.php
user(); $message = "Your account secure with google 2FA"; if($user->two_factor_status == false) $message = "To enable two factor authentication (powered by google) please visit your web dashboard. Click here: " . setRoute("merchant.authorize.google.2fa"); return Response::success(['Request response fetch successfully!'],[ 'status' => $user->two_factor_status, 'message' => $message, ],200); } public function verifyGoogle2Fa(Request $request) { $validator = Validator::make($request->all(),[ 'code' => "required", ]); if($validator->fails()) return Response::error($validator->errors()->all(),[]); $validated = $validator->validate(); $code = $validated['code']; $user = auth()->user(); if(!$user->two_factor_secret) { return Response::error(['Your secret key not stored properly. Please contact with system administrator'],[],400); } if(google_2fa_verify_api($user->two_factor_secret,$code)) { $user->update([ 'two_factor_verified' => true, ]); return Response::success(['Google 2FA successfully verified!'],[],200); }else if(google_2fa_verify($user->two_factor_secret,$code) === false) { return Response::error(['Invalid authentication code'],[],400); } return Response::error(['Failed to login. Please try again'],[],500); } }