123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Http\Middleware;
- use Closure;
- class User
- {
-
- public function handle($request, Closure $next)
- {
- if ($request->input('auth_data')) {
- $authData = explode(':', base64_decode($request->input('auth_data')));
- $user = \App\Models\User::where('password', $authData[1])
- ->where('email', $authData[0])
- ->first();
- if ($user) {
- $request->session()->put('email', $user->email);
- $request->session()->put('id', $user->id);
- }
- }
- if (!$request->session()->get('id')) {
- abort(403, '未登录或登陆已过期');
- }
- return $next($request);
- }
- }
|