mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-17 13:31:52 +00:00
0.0.12
- Add client TZ support + Selectable on user page - Move token auth to GET ?key=XYZ for wider webhook support - Add Multiscrobbler support - Add /api/v1/serverinfo for version information
This commit is contained in:
parent
9866dea36b
commit
67e43b8984
14 changed files with 415 additions and 114 deletions
|
@ -3,18 +3,24 @@ import jwt from 'jwt-decode'
|
|||
import { toast } from 'react-toastify';
|
||||
|
||||
function getHeaders() {
|
||||
// Todo: move this to use Context values instead.
|
||||
// TODO: move this to use Context values instead.
|
||||
const user = JSON.parse(localStorage.getItem('user'));
|
||||
|
||||
if (user && user.jwt) {
|
||||
return { Authorization: 'Bearer ' + user.jwt, changeOrigin: true };
|
||||
var unixtime = Math.round((new Date()).getTime() / 1000);
|
||||
if (user.exp < unixtime) {
|
||||
// TODO: Handle expiry nicer
|
||||
toast.warning("Session expired. Please log in again")
|
||||
}
|
||||
|
||||
return { Authorization: 'Bearer ' + user.jwt };
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function getUserUuid() {
|
||||
// Todo: move this to use Context values instead.
|
||||
// TODO: move this to use Context values instead.
|
||||
const user = JSON.parse(localStorage.getItem('user'));
|
||||
|
||||
if (user && user.uuid) {
|
||||
|
@ -179,6 +185,15 @@ export const getUser = () => {
|
|||
});
|
||||
};
|
||||
|
||||
export const patchUser = (values) => {
|
||||
return axios.patch(process.env.REACT_APP_API_URL + "user", values, { headers: getHeaders() })
|
||||
.then((data) => {
|
||||
return data.data;
|
||||
}).catch((error) => {
|
||||
return handleErrorResp(error)
|
||||
});
|
||||
};
|
||||
|
||||
export const validateResetPassword = (tokenStr) => {
|
||||
return axios.get(process.env.REACT_APP_API_URL + "user/", { headers: getHeaders() })
|
||||
.then((data) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue