Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien2p committed Nov 28, 2023
1 parent bdb8275 commit eb03688
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ export function getAuth0AdminAuthRouter(auth0: Auth0Options, configModule: Confi
},
expiresIn: auth0.admin.expiresIn,
});
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MedusaContainer } from '@medusajs/medusa/dist/types/global';
import {AuthOptions} from "../../types";
import { AuthOptions } from '../../types';

export const AZURE_STORE_STRATEGY_NAME = 'azure-oidc.store.medusa-auth-plugin';
export const AZURE_ADMIN_STRATEGY_NAME = 'azure-oidc.admin.medusa-auth-plugin';
Expand Down Expand Up @@ -88,7 +88,12 @@ export type AzureAuthOption = {
/**
* The default verify callback function will be used if this configuration is not specified
*/
verifyCallback?: (container: MedusaContainer, req: Request, profile: any, strict?: AuthOptions['strict']) => Promise<null | { id: string } | never>;
verifyCallback?: (
container: MedusaContainer,
req: Request,
profile: any,
strict?: AuthOptions['strict']
) => Promise<null | { id: string } | never>;

expiresIn?: number;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MedusaContainer } from '@medusajs/medusa/dist/types/global';
import {AuthOptions} from "../../types";
import { AuthOptions } from '../../types';

export const FACEBOOK_ADMIN_STRATEGY_NAME = 'facebook.admin.medusa-auth-plugin';
export const FACEBOOK_STORE_STRATEGY_NAME = 'facebook.store.medusa-auth-plugin';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { authenticateSessionFactory, signToken } from '../../core/auth-callback-

function firebaseCallbackMiddleware(domain: 'admin' | 'store', configModule: ConfigModule, expiresIn?: number) {
return (req: Request, res: Response) => {
if(req.query.returnAccessToken == 'true') {
if (req.query.returnAccessToken == 'true') {
const token = signToken(domain, configModule, req.user, expiresIn);
res.json({ access_token: token });
return;
Expand Down
24 changes: 7 additions & 17 deletions packages/medusa-plugin-auth/src/core/auth-callback-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,21 @@ import jwt from 'jsonwebtoken';
* will be called.
* @param successAction
*/
export function authCallbackMiddleware(
successAction: (req: Request, res: Response) => void
) {
export function authCallbackMiddleware(successAction: (req: Request, res: Response) => void) {
return (req, res) => {
successAction(req, res);
};
}

export function signToken(domain: 'admin' | 'store', configModule: ConfigModule, user: any, expiresIn?: number) {
if(domain === 'admin') {
return jwt.sign(
{ user_id: user.id, domain: 'admin' },
configModule.projectConfig.jwt_secret,
{
if (domain === 'admin') {
return jwt.sign({ user_id: user.id, domain: 'admin' }, configModule.projectConfig.jwt_secret, {
expiresIn: expiresIn ?? '24h',
}
);
});
} else {
return jwt.sign(
{ customer_id: user.id, domain: 'store' },
configModule.projectConfig.jwt_secret,
{
expiresIn: expiresIn ?? '30d',
}
);
return jwt.sign({ customer_id: user.id, domain: 'store' }, configModule.projectConfig.jwt_secret, {
expiresIn: expiresIn ?? '30d',
});
}
}

Expand Down

1 comment on commit eb03688

@vercel
Copy link

@vercel vercel bot commented on eb03688 Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

medusa-plugins – ./

medusa-plugins.vercel.app
medusa-plugins-git-main-adrien2p.vercel.app
medusa-plugins-adrien2p.vercel.app

Please sign in to comment.