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