fix open redirect
This commit is contained in:
@@ -1,4 +1,26 @@
|
|||||||
let SM = {
|
let SM = {
|
||||||
|
redirectIfSafe: (target) => {
|
||||||
|
if (typeof target !== 'string' || target === '') {
|
||||||
|
window.location.assign('/');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let url;
|
||||||
|
try {
|
||||||
|
url = new URL(target, window.location.origin);
|
||||||
|
} catch (error) {
|
||||||
|
window.location.assign('/');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url.origin !== window.location.origin) {
|
||||||
|
window.location.assign('/');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.location.assign(url.href);
|
||||||
|
},
|
||||||
|
|
||||||
alert: (title, text, type = 'info') =>{
|
alert: (title, text, type = 'info') =>{
|
||||||
const data = {
|
const data = {
|
||||||
position: 'top-end',
|
position: 'top-end',
|
||||||
@@ -84,7 +106,7 @@ let SM = {
|
|||||||
axios.delete(url)
|
axios.delete(url)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if(response.data.success){
|
if(response.data.success){
|
||||||
window.location.href = response.data.redirect;
|
SM.redirectIfSafe(response.data.redirect);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user