Skip to content

Commit

Permalink
Merge pull request #265 from node-real/fix/offchain-auth-expirate
Browse files Browse the repository at this point in the history
feat(dcellar-web-ui): fix readqutoa api auth expirated
  • Loading branch information
aiden-cao authored Nov 14, 2023
2 parents ac38827 + c6d340b commit 6afb5e8
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
14 changes: 11 additions & 3 deletions apps/dcellar-web-ui/src/components/layout/Header/GlobalTasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ export const GlobalTasks = memo<GlobalTasksProps>(function GlobalTasks() {
.catch(async (e: Response | any) => {
console.log('upload error', e);
const { message } = await parseErrorXml(e);
const authExpired = message?.includes('invalid signature');
const authExpired =
message?.includes('invalid signature') ||
message?.includes('user public key is expired');
if (authExpired) {
setOpenAuthModal();
setAuthModal(true);
Expand Down Expand Up @@ -205,7 +207,7 @@ export const GlobalTasks = memo<GlobalTasksProps>(function GlobalTasks() {
privateKey: tmpAccount.privateKey,
}).then(resolve, createTxFault);
if (_createError) {
console.log('createError', _createError)
console.log('createError', _createError);
return dispatch(
setupUploadTaskErrorMsg({
account: loginAccount,
Expand Down Expand Up @@ -250,7 +252,13 @@ export const GlobalTasks = memo<GlobalTasksProps>(function GlobalTasks() {
}),
);
}
dispatch(updateUploadCreateHash({account: loginAccount, id: task.id, createHash: res.transactionHash}))
dispatch(
updateUploadCreateHash({
account: loginAccount,
id: task.id,
createHash: res.transactionHash,
}),
);
}, [signTask]);

// 3. upload
Expand Down
2 changes: 1 addition & 1 deletion apps/dcellar-web-ui/src/facade/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const getCanObjectAccess = async (
seedString,
};
const [info, quota, error] = await getObjectInfoAndBucketQuota(params);
if (error === 'invalid signature') {
if (error === 'invalid signature' || error === 'user public key is expired') {
return [false, E_OFF_CHAIN_AUTH];
}
if (!info) return [false, E_NOT_FOUND];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const renderFee = (
<Flex alignItems="center" mb="4px">
<Text fontSize={'14px'} lineHeight={'28px'} fontWeight={400} color={'readable.tertiary'}>
{key}
{key.toLowerCase() === 'gas fee' && (
{key?.toLowerCase() === 'gas fee' && (
<>
{' '}
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export const ObjectList = memo<ObjectListProps>(function ObjectList() {
address: loginAccount,
};
const [objectInfo, quotaData, error] = await getObjectInfoAndBucketQuota(gParams);
if (error === 'invalid signature') {
if (error === 'invalid signature' || error === 'user public key is expired') {
return onError(E_OFF_CHAIN_AUTH);
}
if (!quotaData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const ObjectNameColumn = memo<ObjectNameColumnProps>(function NameItem({
address: loginAccount,
};
const [objectInfo, quotaData, error] = await getObjectInfoAndBucketQuota(gParams);
if (error === 'invalid signature') {
if (error === 'invalid signature' || error === 'user public key is expired') {
return onError(E_OFF_CHAIN_AUTH);
}
if (objectInfo === null) {
Expand Down
2 changes: 1 addition & 1 deletion apps/dcellar-web-ui/src/pages/share/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const SharePage: NextPage<PageProps> = (props) => {
}

const [objectInfo, quotaData, error] = await getObjectInfoAndBucketQuota(params);
if (error === 'invalid signature') {
if (error === 'invalid signature' || error === 'user public key is expired') {
logout(true);
}
setObjectInfo(objectInfo);
Expand Down
2 changes: 1 addition & 1 deletion apps/dcellar-web-ui/src/store/slices/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export const setupBucketQuota =
});
dispatch(setQuotaLoading(false));
if (quota === null) {
if (error === 'invalid signature') {
if (['invalid signature', 'user public key is expired'].includes(error)) {
dispatch(setAuthModalOpen([true, { action: 'quota', params: { bucketName } }]));
} else {
console.error({ description: error || 'Get bucket read quota error' });
Expand Down

0 comments on commit 6afb5e8

Please sign in to comment.