Page MenuHomeDevCentral
Paste P195

AuthenticatesAndRegistersUsers.diff
ActivePublic

Authored by dereckson on Jun 1 2016, 20:40.
--- AuthenticatesAndRegistersUsers.php 2016-06-01 20:39:59.000000000 +0000
+++ app/Services/AuthenticatesAndRegistersUsers.php 2015-05-22 15:51:25.000000000 +0000
@@ -1,22 +1,23 @@
-<?php namespace Illuminate\Foundation\Auth;
+<?php namespace AuthGrove\Services;
use Illuminate\Http\Request;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\Registrar;
+use Illuminate\Support\Facades\Lang as Lang;
trait AuthenticatesAndRegistersUsers {
/**
* The Guard implementation.
*
- * @var \Illuminate\Contracts\Auth\Guard
+ * @var Guard
*/
protected $auth;
/**
* The registrar implementation.
*
- * @var \Illuminate\Contracts\Auth\Registrar
+ * @var Registrar
*/
protected $registrar;
@@ -71,10 +72,11 @@
public function postLogin(Request $request)
{
$this->validate($request, [
- 'email' => 'required|email', 'password' => 'required',
+ 'username' => 'required',
+ 'password' => 'required',
]);
- $credentials = $request->only('email', 'password');
+ $credentials = $request->only('username', 'password');
if ($this->auth->attempt($credentials, $request->has('remember')))
{
@@ -82,9 +84,9 @@
}
return redirect($this->loginPath())
- ->withInput($request->only('email', 'remember'))
+ ->withInput($request->only('username', 'remember'))
->withErrors([
- 'email' => $this->getFailedLoginMessage(),
+ 'username' => $this->getFailedLoginMessage(),
]);
}
@@ -95,7 +97,7 @@
*/
protected function getFailedLoginMessage()
{
- return 'These credentials do not match our records.';
+ return Lang::get('login.failedLogin');
}
/**
@@ -122,7 +124,7 @@
return $this->redirectPath;
}
- return property_exists($this, 'redirectTo') ? $this->redirectTo : '/home';
+ return property_exists($this, 'redirectTo') ? $this->redirectTo : '/';
}
/**

Event Timeline

dereckson edited the content of this paste. (Show Details)Jun 1 2016, 20:40
dereckson changed the title of this paste from untitled to AuthenticatesAndRegistersUsers.diff.