You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.4 KiB
70 lines
2.4 KiB
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Auth;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\CentralLogics\Helpers;
|
|
use Gregwar\Captcha\CaptchaBuilder;
|
|
use App\Http\Controllers\Controller;
|
|
use Brian2694\Toastr\Facades\Toastr;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Session;
|
|
|
|
class LoginController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->middleware('guest:admin', ['except' => 'logout']);
|
|
}
|
|
|
|
public function login()
|
|
{
|
|
$custome_recaptcha = new CaptchaBuilder;
|
|
$custome_recaptcha->build();
|
|
Session::put('six_captcha', $custome_recaptcha->getPhrase());
|
|
return view('admin-views.auth.login', compact('custome_recaptcha'));
|
|
}
|
|
|
|
public function submit(Request $request)
|
|
{
|
|
$request->validate([
|
|
'email' => 'required|email',
|
|
'password' => 'required|min:6'
|
|
]);
|
|
|
|
/* $recaptcha = Helpers::get_business_settings('recaptcha');
|
|
if (isset($recaptcha) && $recaptcha['status'] == 1) {
|
|
$request->validate([
|
|
'g-recaptcha-response' => [
|
|
function ($attribute, $value, $fail) {
|
|
$secret_key = Helpers::get_business_settings('recaptcha')['secret_key'];
|
|
$response = $value;
|
|
$url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . $secret_key . '&response=' . $response;
|
|
$response = Http::get($url);
|
|
$response = $response->json();
|
|
if (!isset($response['success']) || !$response['success']) {
|
|
$fail(translate('messages.ReCAPTCHA Failed'));
|
|
}
|
|
},
|
|
],
|
|
]);
|
|
} else if(session('six_captcha') != $request->custome_recaptcha)
|
|
{
|
|
Toastr::error(translate('messages.ReCAPTCHA Failed'));
|
|
return back();
|
|
}
|
|
*/
|
|
if (auth('admin')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) {
|
|
return redirect()->route('admin.dashboard');
|
|
}
|
|
|
|
return redirect()->back()->withInput($request->only('email', 'remember'))
|
|
->withErrors([translate('credentials_does_not_match')]);
|
|
}
|
|
|
|
public function logout(Request $request)
|
|
{
|
|
auth()->guard('admin')->logout();
|
|
return redirect()->route('admin.auth.login');
|
|
}
|
|
}
|
|
|