Signed-off-by: XiaoLFeng <gm@x-lf.cn>
This commit is contained in:
parent
3c72e92a62
commit
dd061e26f8
|
@ -15,11 +15,9 @@
|
|||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request as HttpRequest;
|
||||
use Illuminate\Http\Response as HttpResponse;
|
||||
use Illuminate\Mail\Message;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
|
@ -438,6 +436,7 @@ private function apiCustomBlogCheckSendEmail(): void
|
|||
public function apiCustomBlogVerify(HttpRequest $request): JsonResponse
|
||||
{
|
||||
/** @var array $returnData Json的 return 返回值 */
|
||||
/** @var mixed $cookie 保存Cookie数据 */
|
||||
//数据验证
|
||||
$dataCheck = Validator::make($request->all(), [
|
||||
'id' => 'required|int',
|
||||
|
@ -446,6 +445,7 @@ public function apiCustomBlogVerify(HttpRequest $request): JsonResponse
|
|||
]);
|
||||
// 验证数据是否合法
|
||||
if (!$dataCheck->fails()) {
|
||||
$cookie = cookie('friend_edit', '', -1, '/');
|
||||
// 检查内容是否存在
|
||||
$resultBlog = DB::table('blog_link')
|
||||
->select('id', 'blogOwnEmail')
|
||||
|
@ -466,8 +466,7 @@ public function apiCustomBlogVerify(HttpRequest $request): JsonResponse
|
|||
->toArray();
|
||||
if (!empty($resultCode[0]->id)) {
|
||||
// 配置Cookie
|
||||
$Response = new HttpResponse();
|
||||
$Response->withCookie(cookie('friend_edit', password_hash($resultBlog->id, PASSWORD_DEFAULT), 15, '/'));
|
||||
$cookie = cookie('friend_edit', password_hash($resultBlog->id, PASSWORD_DEFAULT), 15, '/',);
|
||||
// 完成验证删除验证码
|
||||
DB::table('code')
|
||||
->delete((int)$resultCode[0]->id);
|
||||
|
@ -540,10 +539,11 @@ public function apiCustomBlogVerify(HttpRequest $request): JsonResponse
|
|||
],
|
||||
];
|
||||
}
|
||||
return Response::json($returnData, $returnData['code']);
|
||||
return Response::json($returnData, $returnData['code'])
|
||||
->cookie($cookie);
|
||||
}
|
||||
|
||||
public function viewEditFriend($friendId): Application|Factory|View|RedirectResponse
|
||||
protected function viewEditFriend(HttpRequest $request, $friendId): Application|Factory|View|RedirectResponse
|
||||
{
|
||||
// 检查内容是否为空
|
||||
if (!empty($friendId)) {
|
||||
|
@ -554,19 +554,27 @@ public function viewEditFriend($friendId): Application|Factory|View|RedirectResp
|
|||
->find($friendId);
|
||||
if (!empty($resultBlog->id)) {
|
||||
// 检查是否存在Cookie作为已验证
|
||||
if (Request::hasCookie('friend_edit')) {
|
||||
if ($request->hasCookie('friend_edit')) {
|
||||
// 检查COOKIE与所验证ID是否匹配
|
||||
if (password_verify($friendId, Request::cookie('friend_edit'))) {
|
||||
if (password_verify($resultBlog->id, $request->cookie('friend_edit'))) {
|
||||
$this->data['blog'] = $resultBlog;
|
||||
$this->data['blogColor'] = DB::table('blog_color')
|
||||
->orderBy('id')
|
||||
->get()
|
||||
->toArray();
|
||||
$this->data['blogSort'] = DB::table('blog_sort')
|
||||
->orderBy('sort')
|
||||
->get()
|
||||
->toArray();
|
||||
return view('function.edit-friend', $this->data);
|
||||
} else {
|
||||
response()->withCookie(cookie('friend_edit', null, time() - 1));
|
||||
return Response::redirectTo(route('function.edit-search'));
|
||||
$cookie = cookie('friend_edit', '', -1, '/');
|
||||
return Response::redirectTo(route('function.edit-search'))
|
||||
->cookie($cookie);
|
||||
}
|
||||
} else {
|
||||
// 验证页面
|
||||
// 加密用户邮箱
|
||||
$this->data['blog'] = $resultBlog;
|
||||
return view('function.edit-check', $this->data);
|
||||
return Response::redirectTo(route('function.edit-searchOnly', $resultBlog->id));
|
||||
}
|
||||
} else {
|
||||
// 不存在这一个ID用户
|
||||
|
|
|
@ -210,19 +210,28 @@ class="relative left-[calc(50%+3rem)] aspect-[1155/678] w-[36.125rem] -translate
|
|||
</div>
|
||||
<div class="ml-3 text-sm font-normal">
|
||||
<span class="mb-1 text-sm font-semibold text-gray-900 dark:text-white">友链已登记</span>
|
||||
<div class="mb-2 text-sm font-normal">已经存有该博客(博客名字、博客地址、博主邮箱不得重复),请确认您没有输入错误吗?<span class="text-red-500">(如果想修改已登记博客,请使用在友链登记邮箱进行注册/登录进行修改)</span></div>
|
||||
<div class="mb-2 text-sm font-normal">已经存有该博客(博客名字、博客地址、博主邮箱不得重复),请确认您没有输入错误吗?<span class="text-red-500">(如果想修改已登记博客,请使用在友链登记邮箱进行注册/登录进行修改)</span>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<div>
|
||||
<a href="{{ route('login') }}" class="inline-flex justify-center w-full px-2 py-1.5 text-xs font-medium text-center text-white bg-blue-600 rounded-lg hover:bg-blue-700 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-500 dark:hover:bg-blue-600 dark:focus:ring-blue-800">登录</a>
|
||||
<a href="{{ route('login') }}"
|
||||
class="inline-flex justify-center w-full px-2 py-1.5 text-xs font-medium text-center text-white bg-blue-600 rounded-lg hover:bg-blue-700 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-500 dark:hover:bg-blue-600 dark:focus:ring-blue-800">登录</a>
|
||||
</div>
|
||||
<div>
|
||||
<a id="edit-friend" href="{{ route('function.edit-friend') }}" class="inline-flex justify-center w-full px-2 py-1.5 text-xs font-medium text-center text-gray-900 bg-white border border-gray-300 rounded-lg hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-gray-200 dark:bg-gray-600 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-700 dark:focus:ring-gray-700">检索</a>
|
||||
<a id="edit-friend" href="{{ route('function.edit-search') }}" class="inline-flex justify-center w-full px-2 py-1.5 text-xs font-medium
|
||||
text-center text-gray-900 bg-white border border-gray-300 rounded-lg hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-gray-200 dark:bg-gray-600 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-700 dark:focus:ring-gray-700">检索</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="ml-auto -mx-1.5 -my-1.5 bg-white text-gray-400 hover:text-gray-900 rounded-lg focus:ring-2 focus:ring-gray-300 p-1.5 hover:bg-gray-100 inline-flex h-8 w-8 dark:text-gray-500 dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700" data-dismiss-target="#toast-interactive" aria-label="Close">
|
||||
<button type="button"
|
||||
class="ml-auto -mx-1.5 -my-1.5 bg-white text-gray-400 hover:text-gray-900 rounded-lg focus:ring-2 focus:ring-gray-300 p-1.5 hover:bg-gray-100 inline-flex h-8 w-8 dark:text-gray-500 dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700"
|
||||
data-dismiss-target="#toast-interactive" aria-label="Close">
|
||||
<span class="sr-only">Close</span>
|
||||
<svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
|
||||
<svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd"
|
||||
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
|
||||
clip-rule="evenodd"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user