Merge branch 'master' into release
This commit is contained in:
commit
8419757e56
@ -126,6 +126,11 @@ const genError = (key = null, message = null, msgCode = null) => {
|
|||||||
const checkSession = async (c, n) => {
|
const checkSession = async (c, n) => {
|
||||||
if (!('session' in c) || !('user' in c.session) || !('loginType' in c.session)) throw genError('NotLogin')
|
if (!('session' in c) || !('user' in c.session) || !('loginType' in c.session)) throw genError('NotLogin')
|
||||||
|
|
||||||
|
c.state.loginUser = {
|
||||||
|
name: c.session.loginType === 'twitich' ? c.session.user.login : c.session.user.name,
|
||||||
|
type: c.session.loginType
|
||||||
|
}
|
||||||
|
|
||||||
return n()
|
return n()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,9 @@ r.post('/login', koaBody(), async (c, n) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
r.get('/session', checkSession, async (c, n) => {
|
r.get('/session', checkSession, async (c, n) => {
|
||||||
c.obj = resObject('Success')
|
c.obj = resObject('Success', {
|
||||||
|
user: c.state.loginUser
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
r.use('/twitch', require('./twitch').routes())
|
r.use('/twitch', require('./twitch').routes())
|
||||||
|
Loading…
Reference in New Issue
Block a user