Commit 64fa34fc by 杨树贤

cookie信息

parent abd66141
......@@ -3,7 +3,9 @@
<component name="ChangeListManager">
<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$/app/Http/Kernel.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Kernel.php" 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$/app/Http/Middleware/AddExtraDataToCookie.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Middleware/AddExtraDataToCookie.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Http/Middleware/EncryptCookies.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Middleware/EncryptCookies.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bootstrap/app.php" beforeDir="false" afterPath="$PROJECT_DIR$/bootstrap/app.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bootstrap/cache/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/bootstrap/cache/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/storage/app/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/storage/app/.gitignore" afterDir="false" />
......@@ -187,7 +189,8 @@
<workItem from="1666835076791" duration="693000" />
<workItem from="1667266026118" duration="40321000" />
<workItem from="1667959054458" duration="183000" />
<workItem from="1667986756173" duration="13398000" />
<workItem from="1667986756173" duration="14315000" />
<workItem from="1668150640953" duration="889000" />
</task>
<servers />
</component>
......
......@@ -7,7 +7,9 @@ use App\Models\UserModel;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Redis;
......@@ -58,6 +60,7 @@ class AuthApiController extends Controller
if ($this->attemptLogin($request)) {
$request->session()->regenerate();
Cookie::queue('sem_email', Auth::user()->email, config('session.lifetime'));
return $this->setSuccess('Login success');
}
......
......@@ -4,6 +4,8 @@ namespace App\Http\Middleware;
use Carbon\Carbon;
use Closure;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cookie;
class AddExtraDataToCookie
{
......@@ -16,13 +18,12 @@ class AddExtraDataToCookie
*/
public function handle($request, Closure $next)
{
if (!cookie('sem_gid')) {
if (empty($_COOKIE['sem_gid'])) {
$time = Carbon::now()->addYear()->timestamp;
$gidKey = '5aEVuH0OzvnY8G5a';
$gid = md5(time() . $gidKey . $time);
setcookie('sem_gid', $gid, $time);
}
return $next($request);
}
}
......@@ -13,5 +13,6 @@ class EncryptCookies extends Middleware
*/
protected $except = [
//
'sem_email',
];
}
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