Added rev_id column. Updated redis calls.
This commit is contained in:
15
lib/auth.js
15
lib/auth.js
@@ -1,4 +1,4 @@
|
||||
import { parseSecureToken, parseToken } from 'next-basics';
|
||||
import { getRandomChars, parseSecureToken, parseToken } from 'next-basics';
|
||||
import { getUser, getWebsite } from 'queries';
|
||||
import debug from 'debug';
|
||||
import { SHARE_TOKEN_HEADER, TYPE_USER, TYPE_WEBSITE } from 'lib/constants';
|
||||
@@ -6,10 +6,19 @@ import { secret } from 'lib/crypto';
|
||||
|
||||
const log = debug('umami:auth');
|
||||
|
||||
export function generateAuthToken() {
|
||||
return getRandomChars(32);
|
||||
}
|
||||
|
||||
export function getAuthToken(req) {
|
||||
const token = req.headers.authorization;
|
||||
|
||||
return token.split(' ')[1];
|
||||
}
|
||||
|
||||
export function parseAuthToken(req) {
|
||||
try {
|
||||
const token = req.headers.authorization;
|
||||
return parseSecureToken(token.split(' ')[1], secret());
|
||||
return parseSecureToken(getAuthToken(req), secret());
|
||||
} catch (e) {
|
||||
log(e);
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user