mirror of
https://github.com/ZeroCatDev/ClassworksKV.git
synced 2026-02-04 16:03:11 +00:00
Compare commits
No commits in common. "fddaf0dffde0c1d2b35c2096dd626f9c64b8d4e2" and "8e3b3df1ae4267ec1ae2f5ffb59e9330a9ab98c4" have entirely different histories.
fddaf0dffd
...
8e3b3df1ae
@ -18,9 +18,9 @@ export const oauthProviders = {
|
|||||||
zerocat: {
|
zerocat: {
|
||||||
clientId: process.env.ZEROCAT_CLIENT_ID,
|
clientId: process.env.ZEROCAT_CLIENT_ID,
|
||||||
clientSecret: process.env.ZEROCAT_CLIENT_SECRET,
|
clientSecret: process.env.ZEROCAT_CLIENT_SECRET,
|
||||||
authorizationURL: "https://zerocat-api.houlang.cloud/oauth/authorize",
|
authorizationURL: "https://zerocat-api.houlangs.com/oauth/authorize",
|
||||||
tokenURL: "https://zerocat-api.houlang.cloud/oauth/token",
|
tokenURL: "https://zerocat-api.houlangs.com/oauth/token",
|
||||||
userInfoURL: "https://zerocat-api.houlang.cloud/oauth/userinfo",
|
userInfoURL: "https://zerocat-api.houlangs.com/oauth/userinfo",
|
||||||
scope: "user:basic user:email",
|
scope: "user:basic user:email",
|
||||||
// 展示相关
|
// 展示相关
|
||||||
name: "ZeroCat",
|
name: "ZeroCat",
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ClassworksKV",
|
"name": "ClassworksKV",
|
||||||
"version": "1.3.9",
|
"version": "1.3.8",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ClassworksKV",
|
"name": "ClassworksKV",
|
||||||
"version": "1.3.9",
|
"version": "1.3.8",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@opentelemetry/auto-instrumentations-node": "^0.59.0",
|
"@opentelemetry/auto-instrumentations-node": "^0.59.0",
|
||||||
"@opentelemetry/exporter-trace-otlp-proto": "^0.205.0",
|
"@opentelemetry/exporter-trace-otlp-proto": "^0.205.0",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ClassworksKV",
|
"name": "ClassworksKV",
|
||||||
"version": "1.3.9",
|
"version": "1.3.8",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./bin/www",
|
"start": "node ./bin/www",
|
||||||
|
|||||||
@ -338,54 +338,6 @@ router.post(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* POST /apps/tokens/:token/set-teacher-name
|
|
||||||
* 设置教师名称 (仅限教师类型的 token)
|
|
||||||
* Body: { name: string }
|
|
||||||
*/
|
|
||||||
router.post(
|
|
||||||
"/tokens/:token/set-teacher-name",
|
|
||||||
errors.catchAsync(async (req, res, next) => {
|
|
||||||
const {token} = req.params;
|
|
||||||
const {name} = req.body;
|
|
||||||
|
|
||||||
if (!name) {
|
|
||||||
return next(errors.createError(400, "需要提供教师名称"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查找 token 对应的应用安装记录
|
|
||||||
const appInstall = await prisma.appInstall.findUnique({
|
|
||||||
where: {token},
|
|
||||||
include: {
|
|
||||||
device: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!appInstall) {
|
|
||||||
return next(errors.createError(404, "Token 不存在"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证 token 类型是否为 teacher
|
|
||||||
if (appInstall.deviceType !== 'teacher') {
|
|
||||||
return next(errors.createError(403, "只有教师类型的 token 可以使用此接口"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新 AppInstall 的 note 字段为教师名称
|
|
||||||
const updatedInstall = await prisma.appInstall.update({
|
|
||||||
where: {id: appInstall.id},
|
|
||||||
data: {note: name},
|
|
||||||
});
|
|
||||||
|
|
||||||
return res.json({
|
|
||||||
success: true,
|
|
||||||
token: updatedInstall.token,
|
|
||||||
name: updatedInstall.note,
|
|
||||||
deviceType: updatedInstall.deviceType,
|
|
||||||
updatedAt: updatedInstall.updatedAt,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PUT /apps/tokens/:token/note
|
* PUT /apps/tokens/:token/note
|
||||||
* 更新令牌的备注信息
|
* 更新令牌的备注信息
|
||||||
|
|||||||
@ -245,7 +245,7 @@ export function initSocket(server) {
|
|||||||
senderInfo: {
|
senderInfo: {
|
||||||
appId: tokenInfo?.appId,
|
appId: tokenInfo?.appId,
|
||||||
deviceType: tokenInfo?.deviceType,
|
deviceType: tokenInfo?.deviceType,
|
||||||
deviceName: tokenInfo?.note,
|
deviceName: tokenInfo?.deviceName,
|
||||||
isReadOnly: tokenInfo?.isReadOnly || false,
|
isReadOnly: tokenInfo?.isReadOnly || false,
|
||||||
note: tokenInfo?.note
|
note: tokenInfo?.note
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user