chore: Move to prettier standard double quotes (#1309)
This commit is contained in:
@ -1,19 +1,19 @@
|
||||
// @flow
|
||||
import JWT from 'jsonwebtoken';
|
||||
import subMinutes from 'date-fns/sub_minutes';
|
||||
import { AuthenticationError } from '../errors';
|
||||
import { User } from '../models';
|
||||
import JWT from "jsonwebtoken";
|
||||
import subMinutes from "date-fns/sub_minutes";
|
||||
import { AuthenticationError } from "../errors";
|
||||
import { User } from "../models";
|
||||
|
||||
function getJWTPayload(token) {
|
||||
let payload;
|
||||
try {
|
||||
payload = JWT.decode(token);
|
||||
} catch (err) {
|
||||
throw new AuthenticationError('Unable to decode JWT token');
|
||||
throw new AuthenticationError("Unable to decode JWT token");
|
||||
}
|
||||
|
||||
if (!payload) {
|
||||
throw new AuthenticationError('Invalid token');
|
||||
throw new AuthenticationError("Invalid token");
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
@ -25,7 +25,7 @@ export async function getUserForJWT(token: string) {
|
||||
try {
|
||||
JWT.verify(token, user.jwtSecret);
|
||||
} catch (err) {
|
||||
throw new AuthenticationError('Invalid token');
|
||||
throw new AuthenticationError("Invalid token");
|
||||
}
|
||||
|
||||
return user;
|
||||
@ -37,7 +37,7 @@ export async function getUserForEmailSigninToken(token: string) {
|
||||
// check the token is within it's expiration time
|
||||
if (payload.createdAt) {
|
||||
if (new Date(payload.createdAt) < subMinutes(new Date(), 10)) {
|
||||
throw new AuthenticationError('Expired token');
|
||||
throw new AuthenticationError("Expired token");
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,13 +46,13 @@ export async function getUserForEmailSigninToken(token: string) {
|
||||
// if user has signed in at all since the token was created then
|
||||
// it's no longer valid, they'll need a new one.
|
||||
if (user.lastSignedInAt > payload.createdAt) {
|
||||
throw new AuthenticationError('Token has already been used');
|
||||
throw new AuthenticationError("Token has already been used");
|
||||
}
|
||||
|
||||
try {
|
||||
JWT.verify(token, user.jwtSecret);
|
||||
} catch (err) {
|
||||
throw new AuthenticationError('Invalid token');
|
||||
throw new AuthenticationError("Invalid token");
|
||||
}
|
||||
|
||||
return user;
|
||||
|
Reference in New Issue
Block a user