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.
Zaimki/src/authenticate.js

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;
}