123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php namespace App\Http\Controllers\Auth;
- use Illuminate\Contracts\Auth\Guard;
- use App\Http\Requests\Auth\LoginRequest;
- use App\Http\Requests\Auth\RegisterRequest;
- class AuthController {
-
- protected $auth;
-
- public function __construct(Guard $auth)
- {
- $this->auth = $auth;
- }
-
- public function showRegistrationForm()
- {
- return view('auth.register');
- }
-
- public function register(RegisterRequest $request)
- {
-
- $this->auth->login($user);
- return redirect('/');
- }
-
- public function showLoginForm()
- {
- return view('auth.login');
- }
-
- public function login(LoginRequest $request)
- {
- if ($this->auth->attempt($request->only('email', 'password')))
- {
- return redirect('/');
- }
- return redirect('/login')->withErrors([
- 'email' => 'These credentials do not match our records.',
- ]);
- }
-
- public function logout()
- {
- $this->auth->logout();
- return redirect('/');
- }
- }
|