14 lines
341 B
JavaScript
14 lines
341 B
JavaScript
import jwt from './jwt';
|
|
|
|
export default ({cookies, headers}) => {
|
|
if (headers.authorization && headers.authorization.startsWith('Bearer ')) {
|
|
return jwt.validate(headers.authorization.substring(7));
|
|
}
|
|
|
|
if (cookies.token && cookies.token !== 'null') {
|
|
return jwt.validate(cookies.token)
|
|
}
|
|
|
|
return null;
|
|
}
|