Skip to content

Commit

Permalink
[net-util] Catch and notify expired refresh token errors
Browse files Browse the repository at this point in the history
  • Loading branch information
m4heshd committed Jan 22, 2024
1 parent 011c24a commit 238e3b4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ That's it. Now you're ready to go.
- [x] Migrate to Vite (dev)
- [x] Support for concurrent multi-fragment download
- [x] Ability to restart failed/canceled downloads
- [x] Support for downloading custom formats
- [ ] Support for more architectures, including ARM-based systems
- [ ] Mobile-responsive Web UI
- [ ] Make completed files downloadable right from the UFC Ripper Web UI (hosted)
Expand Down
22 changes: 15 additions & 7 deletions server-modules/net-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,22 @@ async function refreshAuth() {
proxy: getProxyConfig()
};

const {data} = await axios(config);
try {
const {data} = await axios(config);

if (data?.authorisationToken) {
writeConfig({
authToken: data.authorisationToken
}, false);
} else {
throw createUFCRError('No auth returned');
if (data?.authorisationToken) {
writeConfig({
authToken: data.authorisationToken
}, false);
} else {
throw createUFCRError('No auth returned');
}
} catch (error) {
if (error.response?.status === 404) {
throw createUFCRError(error, 'Your Fight Pass login has expired. Please logout and login again');
} else {
throw createUFCRError(error, 'An unknown error has occurred while trying to refresh the authorization token');
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/components/ModConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
<nav class="v-switch">
<div class="max">
<h6>Use proxy</h6>
<div>Use the following proxy for API requests</div>
<div>Use the following proxy for API requests (downloads will not be proxied through this server)</div>
</div>
<label class="switch">
<input
Expand Down Expand Up @@ -524,6 +524,10 @@ function save() {
}
&__proxy {
& > .v-switch {
margin-bottom: 20px;
}
&__split-section {
display: grid;
grid-template-columns: 1fr 1fr;
Expand Down

0 comments on commit 238e3b4

Please sign in to comment.