forked from ledgersmb/LedgerSMB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
724 additions
and
1,459 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* global globalThis */ | ||
|
||
const { TextEncoder, TextDecoder } = require('node:util') | ||
|
||
Object.defineProperties(globalThis, { | ||
TextDecoder: { value: TextDecoder }, | ||
TextEncoder: { value: TextEncoder }, | ||
}) | ||
|
||
const { Blob } = require('node:buffer') | ||
// const { fetch, Headers, FormData, Request, Response } = require('undici') | ||
|
||
Object.defineProperties(globalThis, { | ||
// fetch: { value: fetch, writable: true }, | ||
Blob: { value: Blob }, | ||
// Headers: { value: Headers }, | ||
// FormData: { value: FormData }, | ||
// Request: { value: Request }, | ||
// Response: { value: Response }, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,40 @@ | ||
import { rest } from 'msw'; | ||
import { http, HttpResponse } from 'msw'; | ||
|
||
export const loginHandlers = [ | ||
|
||
rest.post('login.pl', async (req, res, ctx) => { | ||
http.post('login.pl', async ({ request }) => { | ||
|
||
const action = req.url.searchParams.get('action'); | ||
const params = await req.json(); | ||
const url = new URL(request.url); | ||
const action = url.searchParams.get('action'); | ||
const params = await request.json(); | ||
const username = params.login; | ||
const password = params.password; | ||
const company = params.company; | ||
|
||
if ( action === 'authenticate' ) { | ||
if ( username === 'MyUser' && password === 'MyPassword' && company === 'MyCompany' ) { | ||
window.location.assign('http://lsmb/erp.pl?action=root'); | ||
return res( | ||
ctx.status(200) | ||
); | ||
return new HttpResponse(null, { | ||
status: 200 | ||
}) | ||
} | ||
if ( username && password && company === 'MyOldCompany' ) { | ||
return res( | ||
ctx.status(521) | ||
); | ||
return new HttpResponse(null, { | ||
status: 521 | ||
}) | ||
} | ||
if ( username === 'BadUser' && password && company ) { | ||
return res( | ||
ctx.status(401) | ||
); | ||
return new HttpResponse(null, { | ||
status: 401 | ||
}) | ||
} | ||
} | ||
if (username === 'My' && password === 'My' && company === 'My') { | ||
return res( | ||
ctx.status(500) | ||
); | ||
return new HttpResponse(null, { | ||
status: 500 | ||
}) | ||
} | ||
return res.networkError('Failed to connect'); | ||
return HttpResponse.error('Failed to connect'); | ||
}) | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.