This commit is contained in:
@@ -22,7 +22,7 @@ export interface AuthMethods {
|
||||
getAuthStrategy(method?: STRATEGIES): Strategy | false;
|
||||
getResetLink(route: string): Promise<string | undefined>;
|
||||
getResetToken(): Promise<string | undefined>;
|
||||
getToken(props?: Omit<TokenProps, 'sub'>): string;
|
||||
getToken(props?: Omit<TokenProps, 'sub'> | void): string;
|
||||
setPassword(password: string): Promise<boolean>;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import { sign } from './jwt';
|
||||
export const getAuthenticationBundle = async (username: string, password: string) => {
|
||||
const auth = await Auth.findByUsername(username).catch();
|
||||
const isAuthenticated = !!auth && (auth as AuthModel).authenticate(password);
|
||||
const record = isAuthenticated ? (auth as AuthPrivate).record : null;
|
||||
const token = isAuthenticated ? (auth as AuthModel).getToken() : sign();
|
||||
const record = isAuthenticated ? (auth as AuthPrivate).record as string : null;
|
||||
const token = sign(record || undefined);
|
||||
return {
|
||||
record,
|
||||
token,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import jsonwebtoken, { JwtPayload } from 'jsonwebtoken';
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
export interface TokenProps {
|
||||
aud?: string;
|
||||
|
||||
Reference in New Issue
Block a user