Esempio n. 1
0
 /**
  * @param Request $request
  * @return \Response
  */
 public function login(Request $request)
 {
     if ($request->has('identifier') && $request->has('password')) {
         switch (\Auth::verify(['identifier' => $request->get('identifier'), 'password' => $request->get('password')], $request->has('remember'))) {
             case Verify::SUCCESS:
                 \Session::put('background', auth()->user()->background);
                 return redirect()->back()->with('success', 'Login successful');
             case Verify::INVALID_CREDENTIALS:
                 return redirect()->back()->with('error', 'Invalid credentials');
             case Verify::DISABLED:
                 $user = User::whereUsername($request->get('identifier'))->orWhere('email', $request->get('identifier'))->first();
                 if ($user->banend->eq(Carbon::create(0, 0, 0, 0, 0, 0))) {
                     return redirect()->back()->with('error', 'You are permanently banned for \'' . $user->banreason . '\'.');
                 }
                 // if ban expired unban and relogin.
                 if ($user->banend->lt(Carbon::now())) {
                     $user->banend = null;
                     $user->disabled = 0;
                     $user->banreason = null;
                     $user->save();
                     return $this->login($request);
                 }
                 return redirect()->back()->with('error', 'You are banned for another ' . $user->banend->diffForHumans(null, true) . '. Reason: \'' . $user->banreason . '\'');
             case Verify::UNVERIFIED:
                 return redirect()->back()->with('error', 'Please verify your account');
         }
     }
     return redirect()->back()->with('error', 'Missing credentials');
 }
Esempio n. 2
0
 /**
  * @param Request $request
  * @return \Response
  */
 public function login(Request $request)
 {
     if ($request->has('identifier') && $request->has('password')) {
         switch (\Auth::verify(['identifier' => $request->get('identifier'), 'password' => $request->get('password')], $request->has('remember'))) {
             case Verify::SUCCESS:
                 \Session::put('background', auth()->user()->background);
                 return redirect()->back()->with('success', 'Login successful');
             case Verify::INVALID_CREDENTIALS:
                 return redirect()->back()->with('error', 'Invalid credentials');
             case Verify::DISABLED:
                 return redirect()->back()->with('error', 'You are banned.');
             case Verify::UNVERIFIED:
                 return redirect()->back()->with('error', 'Please verify your account');
         }
     }
     return redirect()->back()->with('error', 'Missing credentials');
 }