@@ -232,8 +232,8 @@ router.post('/config', auth, async (req, res) => {
232232
233233router . post ( '/session' , async ( req , res ) => {
234234 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
237237 const allowRegister = ( await getCacheConfig ( ) ) . siteConfig . registerEnabled
238238 res . send ( { status : 'Success' , message : '' , data : { auth : hasAuth , allowRegister, model : currentModel ( ) } } )
239239 }
@@ -256,14 +256,14 @@ router.post('/user-login', async (req, res) => {
256256 throw new Error ( '请去邮箱中验证 | Please verify in the mailbox' )
257257 throw new Error ( '用户不存在或密码错误 | User does not exist or incorrect password.' )
258258 }
259-
259+ const config = await getCacheConfig ( )
260260 const token = jwt . sign ( {
261261 name : user . name ? user . name : user . email ,
262262 avatar : user . avatar ,
263263 description : user . description ,
264264 userId : user . _id ,
265265 root : username . toLowerCase ( ) === process . env . ROOT_USER ,
266- } , process . env . AUTH_SECRET_KEY )
266+ } , config . siteConfig . loginSalt . trim ( ) )
267267 res . send ( { status : 'Success' , message : '登录成功 | Login successfully' , data : { token } } )
268268 }
269269 catch ( error ) {
0 commit comments