- 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:
Daniel Mason 2021-04-03 01:11:05 +13:00
parent 9866dea36b
commit 67e43b8984
Signed by: idanoo
GPG key ID: 387387CDBC02F132
14 changed files with 415 additions and 114 deletions

View file

@ -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) => {