Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers\Admin;
  4.  
  5. use Auth;
  6. use App\Http\Controllers\Controller;
  7. use Illuminate\Http\Request;
  8. use Illuminate\Support\Facades\Session;
  9. use Validator;
  10.  
  11. class LoginController extends Controller
  12. {
  13.  
  14. public function __construct()
  15. {
  16. $this->middleware('verification');
  17. }
  18.  
  19. public function show()
  20. {
  21. return view("admin.login");
  22. }
  23.  
  24. public function execute(Request $request)
  25. {
  26. Validator::make($request->all(),
  27. [
  28. 'g-recaptcha-response' => 'required|captcha'
  29. ],
  30. [
  31. 'required' => "Подтвердите, что Вы не робот!",
  32. 'captcha' => "Неправильно введена капча!"
  33. ])->validate();
  34.  
  35.  
  36. // Проверка данных входа
  37.  
  38. if (Auth::attempt(['email' => $request->email, 'password' => $request->password,"role_id" => 1])) {
  39.  
  40. Session::put('admin', Auth::user()->email);
  41. return redirect()->route("page.create");
  42.  
  43.  
  44. } else {
  45. return redirect()
  46. ->back()
  47. ->withInput($request->all(["email"]))
  48. ->withErrors(
  49. [
  50. 'password' => "Неверные данные. Возможно у Вас нет прав администратора."
  51. ]);
  52. }
  53.  
  54. }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement