Commit 3638edfd by 杨树贤

登陆接口

parent 68fbc65c
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="fb90add0-1393-48c2-9f26-72365d42cd03" name="变更" comment=""> <list default="true" id="fb90add0-1393-48c2-9f26-72365d42cd03" name="变更" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Http/Controllers/Api/AuthApiController.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/Api/AuthApiController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/routes/api.php" beforeDir="false" afterPath="$PROJECT_DIR$/routes/api.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/routes/web.php" beforeDir="false" afterPath="$PROJECT_DIR$/routes/web.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/storage/app/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/storage/app/.gitignore" afterDir="false" /> <change beforePath="$PROJECT_DIR$/storage/app/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/storage/app/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/storage/app/public/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/storage/app/public/.gitignore" afterDir="false" /> <change beforePath="$PROJECT_DIR$/storage/app/public/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/storage/app/public/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/storage/framework/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/storage/framework/.gitignore" afterDir="false" /> <change beforePath="$PROJECT_DIR$/storage/framework/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/storage/framework/.gitignore" afterDir="false" />
......
...@@ -8,6 +8,7 @@ use Illuminate\Foundation\Auth\ThrottlesLogins; ...@@ -8,6 +8,7 @@ use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
class AuthApiController extends Controller class AuthApiController extends Controller
{ {
...@@ -16,22 +17,25 @@ class AuthApiController extends Controller ...@@ -16,22 +17,25 @@ class AuthApiController extends Controller
public function login(Request $request) public function login(Request $request)
{ {
$this->validateLogin($request); $validator = Validator::make($request->all(), [
'email' => 'required|string|email|max:255',
if (method_exists($this, 'hasTooManyLoginAttempts') && 'password' => 'required|string|min:8|confirmed',
$this->hasTooManyLoginAttempts($request)) { ], [
$this->fireLockoutEvent($request); 'password.min' => 'Password must be at least 8 characters long.'
]);
return $this->sendLockoutResponse($request);
if ($validator->fails()) {
return $this->setError($validator->errors()->first());
} }
if ($this->attemptLogin($request)) { if ($this->attemptLogin($request)) {
return $this->sendLoginResponse($request); $request->session()->regenerate();
return $this->setSuccess('login success');
} }
$this->incrementLoginAttempts($request); $this->incrementLoginAttempts($request);
return $this->sendFailedLoginResponse($request); return $this->setError('login failure');
} }
} }
...@@ -14,8 +14,11 @@ use Illuminate\Support\Facades\Route; ...@@ -14,8 +14,11 @@ use Illuminate\Support\Facades\Route;
| |
*/ */
Route::middleware(['auth.api'])->group(function () { Route::middleware([])->namespace('Api')->group(function () {
Route::get('/user', function (Request $request) { Route::POST('/user/login', 'AuthApiController@login');
return $request->user();
});
}); });
//Route::middleware(['auth'])->namespace('Api')->group(function () {
// Route::POST('/user/login', 'AuthApiController@login');
//});
...@@ -14,12 +14,15 @@ use Illuminate\Support\Facades\Route; ...@@ -14,12 +14,15 @@ use Illuminate\Support\Facades\Route;
| |
*/ */
Auth::routes(['verify' => true]); //Auth::routes(['verify' => true]);
Route::get('/', 'HomeController@index')->name('home'); Route::middleware(['auth'])->group(function () {
Route::get('/test', function () {
return 'Test Page';
});
});
Route::get('/', 'HomeController@index')->name('home');
Route::get('/forget', 'AuthController@forget')->name('forget'); Route::get('/forget', 'AuthController@forget')->name('forget');
Route::get('/about/company', 'AboutController@company')->name('about.company'); Route::get('/about/company', 'AboutController@company')->name('about.company');
Route::get('/about/certification', 'AboutController@certification')->name('about.certification'); Route::get('/about/certification', 'AboutController@certification')->name('about.certification');
//Route::get('/', 'HomeController@index')->name('home')->middleware('verified');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment