-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 权限验证功能 * chore: v2.10.0 * feat: 500 服务异常页面 * feat: 只有结束才会滚动到底部 * chore: 修改 CHANGELOG * chore: 不存在时输出默认报错
- Loading branch information
1 parent
a2ffa3c
commit ffd4da9
Showing
30 changed files
with
376 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "chatgpt-web", | ||
"version": "2.9.3", | ||
"version": "2.10.0", | ||
"private": false, | ||
"description": "ChatGPT Web", | ||
"author": "ChenZhaoYu <[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const auth = async (req, res, next) => { | ||
const AUTH_SECRET_KEY = process.env.AUTH_SECRET_KEY | ||
if (typeof AUTH_SECRET_KEY === 'string' && AUTH_SECRET_KEY.length > 0) { | ||
try { | ||
const Authorization = req.header('Authorization') | ||
if (!Authorization || Authorization.replace('Bearer ', '').trim() !== AUTH_SECRET_KEY.trim()) | ||
throw new Error('Error: 无访问权限 | No access rights') | ||
next() | ||
} | ||
catch (error) { | ||
res.send({ status: 'Unauthorized', message: error.message ?? 'Please authenticate.', data: null }) | ||
} | ||
} | ||
else { | ||
next() | ||
} | ||
} | ||
|
||
export { auth } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { Router } from 'vue-router' | ||
import { useAuthStoreWithout } from '@/store/modules/auth' | ||
|
||
export function setupPageGuard(router: Router) { | ||
router.beforeEach(async (from, to, next) => { | ||
const authStore = useAuthStoreWithout() | ||
if (!authStore.session) { | ||
try { | ||
const data = await authStore.getSession() | ||
if (String(data.auth) === 'false' && authStore.token) | ||
authStore.removeToken() | ||
next() | ||
} | ||
catch (error) { | ||
if (from.path !== '/500') | ||
next({ name: '500' }) | ||
else | ||
next() | ||
} | ||
} | ||
else { | ||
next() | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ss } from '@/utils/storage' | ||
|
||
const LOCAL_NAME = 'SECRET_TOKEN' | ||
|
||
export function getToken() { | ||
return ss.get(LOCAL_NAME) | ||
} | ||
|
||
export function setToken(token: string) { | ||
return ss.set(LOCAL_NAME, token) | ||
} | ||
|
||
export function removeToken() { | ||
return ss.remove(LOCAL_NAME) | ||
} |
Oops, something went wrong.