Skip to content

Commit 844828b

Browse files
authored
Merge pull request #2 from warrant-dev/FixWarrantsProcessing
Deep clone warrants param before processing
2 parents 7f89f66 + 3b37625 commit 844828b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/middleware.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export const authorize = (options: MiddlewareOptions) => {
99
await next(async (vm: any) => {
1010
const { op, warrants, redirectTo } = options;
1111

12-
warrants.forEach((warrant) => {
12+
let warrantsToCheck = [...warrants].map(warrant => ({...warrant}));
13+
warrantsToCheck.forEach((warrant) => {
1314
if (to.params[warrant.objectId]) {
1415
/** @ts-ignore */
1516
warrant.objectId = to.params[warrant.objectId];
@@ -20,7 +21,7 @@ export const authorize = (options: MiddlewareOptions) => {
2021
}
2122
})
2223

23-
const hasWarrant = await vm.$warrant.hasWarrant({ op, warrants });
24+
const hasWarrant = await vm.$warrant.hasWarrant({ op, warrants: warrantsToCheck });
2425
if (!hasWarrant) {
2526
next({ path: redirectTo });
2627
} else {

0 commit comments

Comments
 (0)