修复退出登录获取token出错

This commit is contained in:
hanhh 2021-09-29 23:09:13 +08:00
parent feb22f25b8
commit 5655591215

View File

@ -115,9 +115,10 @@ export function createRandomString(min: number, max: number): string {
} }
export function getToken(req: any) { export function getToken(req: any) {
const { authorization } = req.headers; const { authorization = '' } = req.headers;
if (authorization && authorization.split(' ')[0] === 'Bearer') { if (authorization && authorization.split(' ')[0] === 'Bearer') {
return (authorization.split(' ')[1] as string) return (authorization as string)
.replace('Bearer ', '')
.replace('mobile-', '') .replace('mobile-', '')
.replace('desktop-', ''); .replace('desktop-', '');
} }