-
Notifications
You must be signed in to change notification settings - Fork 35
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
4 changed files
with
55 additions
and
11 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
20 changes: 20 additions & 0 deletions
20
admin-frontend/src/features/cookieManager/cookieValidateReq.ts
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 @@ | ||
import { AppThunk } from '../../app/store'; | ||
import { baseUrl } from '../../utils/urls'; | ||
|
||
// eslint-disable-next-line | ||
export const validCookie = | ||
(siteName: string, content: string): AppThunk<Promise<string>> => async (_, getState) => { | ||
const url = `${baseUrl}cookie/validate?site_name=${siteName}&content=${content}`; | ||
const state = getState(); | ||
const authToken = state.auth.token; | ||
const res = await fetch(url, { | ||
headers: { | ||
Authorization: `Bearer ${authToken}`, | ||
}, | ||
method: 'POST', | ||
}); | ||
const resObj = await res.json(); | ||
return resObj.ok; | ||
}; | ||
|
||
export default validCookie; |
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