This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2020-10-15 11:55:24 -07:00
|
|
|
import jwt from './jwt';
|
|
|
|
|
2020-11-02 10:31:05 -08:00
|
|
|
export default ({cookies, headers}) => {
|
|
|
|
if (headers.authorization && headers.authorization.startsWith('Bearer ')) {
|
|
|
|
return jwt.validate(headers.authorization.substring(7));
|
2020-10-15 11:55:24 -07:00
|
|
|
}
|
|
|
|
|
2020-11-02 10:31:05 -08:00
|
|
|
if (cookies.token && cookies.token !== 'null') {
|
|
|
|
return jwt.validate(cookies.token)
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2020-10-15 11:55:24 -07:00
|
|
|
}
|