mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-01-15 01:14:27 -05:00
fix: use session storage for share token
This commit is contained in:
parent
57cb683c64
commit
5ea63fb60b
1 changed files with 4 additions and 4 deletions
|
@ -21,7 +21,7 @@ const completeShare = async (id: string) => {
|
|||
};
|
||||
|
||||
const get = async (id: string): Promise<Share> => {
|
||||
const shareToken = localStorage.getItem(`share_${id}_token`);
|
||||
const shareToken = sessionStorage.getItem(`share_${id}_token`);
|
||||
return (
|
||||
await api.get(`shares/${id}`, {
|
||||
headers: { "X-Share-Token": shareToken ?? "" },
|
||||
|
@ -30,7 +30,7 @@ const get = async (id: string): Promise<Share> => {
|
|||
};
|
||||
|
||||
const getMetaData = async (id: string): Promise<ShareMetaData> => {
|
||||
const shareToken = localStorage.getItem(`share_${id}_token`);
|
||||
const shareToken = sessionStorage.getItem(`share_${id}_token`);
|
||||
return (
|
||||
await api.get(`shares/${id}/metaData`, {
|
||||
headers: { "X-Share-Token": shareToken ?? "" },
|
||||
|
@ -49,7 +49,7 @@ const getMyShares = async (): Promise<MyShare[]> => {
|
|||
const getShareToken = async (id: string, password?: string) => {
|
||||
const { token } = (await api.post(`/shares/${id}/token`, { password })).data;
|
||||
|
||||
localStorage.setItem(`share_${id}_token`, token);
|
||||
sessionStorage.setItem(`share_${id}_token`, token);
|
||||
};
|
||||
|
||||
const isShareIdAvailable = async (id: string): Promise<boolean> => {
|
||||
|
@ -57,7 +57,7 @@ const isShareIdAvailable = async (id: string): Promise<boolean> => {
|
|||
};
|
||||
|
||||
const getFileDownloadUrl = async (shareId: string, fileId: string) => {
|
||||
const shareToken = localStorage.getItem(`share_${shareId}_token`);
|
||||
const shareToken = sessionStorage.getItem(`share_${shareId}_token`);
|
||||
return (
|
||||
await api.get(`shares/${shareId}/files/${fileId}/download`, {
|
||||
headers: { "X-Share-Token": shareToken ?? "" },
|
||||
|
|
Loading…
Add table
Reference in a new issue