Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers\Admin;
- use Auth;
- use App\Http\Controllers\Controller;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Session;
- use Validator;
- class LoginController extends Controller
- {
- public function __construct()
- {
- $this->middleware('verification');
- }
- public function show()
- {
- return view("admin.login");
- }
- public function execute(Request $request)
- {
- Validator::make($request->all(),
- [
- 'g-recaptcha-response' => 'required|captcha'
- ],
- [
- 'required' => "Подтвердите, что Вы не робот!",
- 'captcha' => "Неправильно введена капча!"
- ])->validate();
- // Проверка данных входа
- if (Auth::attempt(['email' => $request->email, 'password' => $request->password,"role_id" => 1])) {
- Session::put('admin', Auth::user()->email);
- return redirect()->route("page.create");
- } else {
- return redirect()
- ->back()
- ->withInput($request->all(["email"]))
- ->withErrors(
- [
- 'password' => "Неверные данные. Возможно у Вас нет прав администратора."
- ]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement