@@ -232,8 +232,8 @@ router.post('/config', auth, async (req, res) => {
232
232
233
233
router . post ( '/session' , async ( req , res ) => {
234
234
try {
235
- const AUTH_SECRET_KEY = process . env . AUTH_SECRET_KEY
236
- const hasAuth = typeof AUTH_SECRET_KEY === 'string' && AUTH_SECRET_KEY . length > 0
235
+ const config = await getCacheConfig ( )
236
+ const hasAuth = config . siteConfig . loginEnabled
237
237
const allowRegister = ( await getCacheConfig ( ) ) . siteConfig . registerEnabled
238
238
res . send ( { status : 'Success' , message : '' , data : { auth : hasAuth , allowRegister, model : currentModel ( ) } } )
239
239
}
@@ -256,14 +256,14 @@ router.post('/user-login', async (req, res) => {
256
256
throw new Error ( '请去邮箱中验证 | Please verify in the mailbox' )
257
257
throw new Error ( '用户不存在或密码错误 | User does not exist or incorrect password.' )
258
258
}
259
-
259
+ const config = await getCacheConfig ( )
260
260
const token = jwt . sign ( {
261
261
name : user . name ? user . name : user . email ,
262
262
avatar : user . avatar ,
263
263
description : user . description ,
264
264
userId : user . _id ,
265
265
root : username . toLowerCase ( ) === process . env . ROOT_USER ,
266
- } , process . env . AUTH_SECRET_KEY )
266
+ } , config . siteConfig . loginSalt . trim ( ) )
267
267
res . send ( { status : 'Success' , message : '登录成功 | Login successfully' , data : { token } } )
268
268
}
269
269
catch ( error ) {
0 commit comments