修复认证循环重定向问题
This commit is contained in:
@@ -7,13 +7,18 @@
|
|||||||
- 中间件 Limiter
|
- 中间件 Limiter
|
||||||
- 购买套餐页的冗余组件
|
- 购买套餐页的冗余组件
|
||||||
- 确认各个页面操作列的内容
|
- 确认各个页面操作列的内容
|
||||||
- 提取后刷新提取页套餐可用余量
|
|
||||||
- 首次登录弹窗:需要设置初始密码,展示 实名->购买->提取 的流程介绍
|
- 首次登录弹窗:需要设置初始密码,展示 实名->购买->提取 的流程介绍
|
||||||
- 丰富账单页表格内容与样式
|
- 丰富账单页表格内容与样式
|
||||||
- 后台页面:
|
- 后台页面:
|
||||||
- 提取记录
|
- 提取记录
|
||||||
- 使用记录
|
- 使用记录
|
||||||
- 登录流程有问题,在人机验证前不允许提交登录请求
|
- 登录流程优化,在人机验证前不允许提交登录请求
|
||||||
|
|
||||||
|
- 账单页面,可以继续完成未支付的订单
|
||||||
|
- 需要先验证订单是否已完成支付
|
||||||
|
- 如果未完成支付,才根据保存的支付链接弹出二维码
|
||||||
|
- 封装二维码组件,如果以后需要调整二维码大小可以快速操作
|
||||||
|
- 弃用 form 组件中 onSubmit 参数,统一使用 handler 参数
|
||||||
|
|
||||||
### 下阶段
|
### 下阶段
|
||||||
|
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ async function postCall<R = undefined>(rawResp: Promise<ApiResponse<R>>) {
|
|||||||
].some(item => item.test(pathname))
|
].some(item => item.test(pathname))
|
||||||
|
|
||||||
if (match && !resp.success && resp.status === 401) {
|
if (match && !resp.success && resp.status === 401) {
|
||||||
|
console.log('🚗🚗🚗🚗🚗 非正常重定向 🚗🚗🚗🚗🚗')
|
||||||
redirect('/login?force=true')
|
redirect('/login?force=true')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,35 +95,35 @@ export default function Extract(props: ExtractProps) {
|
|||||||
const type = useRef<'copy' | 'open'>('open')
|
const type = useRef<'copy' | 'open'>('open')
|
||||||
const onSubmit = async (values: z.infer<typeof schema>) => {
|
const onSubmit = async (values: z.infer<typeof schema>) => {
|
||||||
switch (type.current) {
|
switch (type.current) {
|
||||||
case 'copy':
|
case 'copy':
|
||||||
const url = new URL(window.location.href).origin
|
const url = new URL(window.location.href).origin
|
||||||
const text = `${url}${params}`
|
const text = `${url}${params}`
|
||||||
|
|
||||||
// 使用 clipboard API 复制链接
|
// 使用 clipboard API 复制链接
|
||||||
let copied = false
|
let copied = false
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(text)
|
await navigator.clipboard.writeText(text)
|
||||||
copied = true
|
copied = true
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.log('剪贴板 API 调用失败,尝试备选方案')
|
console.log('剪贴板 API 调用失败,尝试备选方案')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用 document.execCommand 作为备选方案
|
// 使用 document.execCommand 作为备选方案
|
||||||
if (!copied) {
|
if (!copied) {
|
||||||
const textarea = document.createElement('textarea')
|
const textarea = document.createElement('textarea')
|
||||||
textarea.value = text
|
textarea.value = text
|
||||||
document.body.appendChild(textarea)
|
document.body.appendChild(textarea)
|
||||||
textarea.select()
|
textarea.select()
|
||||||
document.execCommand('copy')
|
document.execCommand('copy')
|
||||||
document.body.removeChild(textarea)
|
document.body.removeChild(textarea)
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.success('链接已复制到剪贴板')
|
toast.success('链接已复制到剪贴板')
|
||||||
break
|
break
|
||||||
case 'open':
|
case 'open':
|
||||||
window.open(params, '_blank')
|
window.open(params, '_blank')
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,24 +28,23 @@ export async function middleware(request: NextRequest) {
|
|||||||
console.log('❌ 刷新访问令牌失败', e)
|
console.log('❌ 刷新访问令牌失败', e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果刷新访问令牌成功,则继续访问之前的页面
|
// 验证访问令牌
|
||||||
const isLogin = request.nextUrl.pathname === '/login'
|
if (request.cookies.get('auth_token')) {
|
||||||
const redirect = request.nextUrl.searchParams.get('redirect')
|
|
||||||
if (isLogin && redirect) {
|
// 如果刷新访问令牌成功,则继续访问之前的页面
|
||||||
console.log('redirect to', redirect)
|
const isLogin = request.nextUrl.pathname === '/login'
|
||||||
return NextResponse.redirect(`${request.nextUrl.origin}${redirect}`)
|
const hasRedirect = request.nextUrl.searchParams.get('redirect')
|
||||||
|
if (isLogin && hasRedirect) {
|
||||||
|
return NextResponse.redirect(`${request.nextUrl.origin}${hasRedirect}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
// 没有访问令牌不允许访问 admin 页面
|
|
||||||
const isAdmin = [
|
// 没有访问令牌不允许访问 admin 页面
|
||||||
RegExp(`^/admin.*`),
|
const isAdmin = request.nextUrl.pathname.startsWith('/admin')
|
||||||
].some(item => item.test(request.nextUrl.pathname))
|
if (isAdmin) {
|
||||||
|
return NextResponse.redirect(`${request.nextUrl.origin}/login?redirect=${request.nextUrl.pathname}`)
|
||||||
const accessToken = request.cookies.get('auth_token')
|
}
|
||||||
|
|
||||||
if (isAdmin && !accessToken) {
|
|
||||||
console.log('🚗🚗🚗🚗🚗 非正常重定向 🚗🚗🚗🚗🚗')
|
|
||||||
return NextResponse.redirect(`${request.nextUrl.origin}/login?redirect=${request.nextUrl.pathname}`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.next({request})
|
return NextResponse.next({request})
|
||||||
|
|||||||
Reference in New Issue
Block a user