added automatic logout
All checks were successful
SimcoDash/simcompanies-dashboard/pipeline/head This commit looks good
All checks were successful
SimcoDash/simcompanies-dashboard/pipeline/head This commit looks good
This commit is contained in:
@@ -16,6 +16,21 @@ export default function ChangePassword(props) {
|
||||
const [statusText, setStatusText] = React.useState(null);
|
||||
const [status, setStatus] = React.useState(null);
|
||||
|
||||
const logout = async () => {
|
||||
await fetch(`/simcompanies/API/user/logout`, {
|
||||
method: 'DELETE',
|
||||
mode: 'cors',
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
redirect: 'follow',
|
||||
referrerPolicy: 'no-referrer'
|
||||
}).then(
|
||||
() => { window.location.reload() }
|
||||
)
|
||||
}
|
||||
|
||||
const postSetPassword = async (url, data) => {
|
||||
|
||||
const response = await fetch(url, {
|
||||
@@ -33,6 +48,9 @@ export default function ChangePassword(props) {
|
||||
const text = await response.text()
|
||||
await setStatusText(text)
|
||||
setStatus(response.status)
|
||||
if (response.status === 200) {
|
||||
setTimeout(() => { logout() }, 2000)
|
||||
}
|
||||
setDisabled(false)
|
||||
setTimeout(() => { setStatus(null) }, 2000)
|
||||
}
|
||||
|
||||
@@ -14,6 +14,21 @@ export default function ChangeUsername(props) {
|
||||
const [statusText, setStatusText] = React.useState(null);
|
||||
const [status, setStatus] = React.useState(null);
|
||||
|
||||
const logout = async () => {
|
||||
await fetch(`/simcompanies/API/user/logout`, {
|
||||
method: 'DELETE',
|
||||
mode: 'cors',
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
redirect: 'follow',
|
||||
referrerPolicy: 'no-referrer'
|
||||
}).then(
|
||||
() => { window.location.reload() }
|
||||
)
|
||||
}
|
||||
|
||||
const postSetName = async (url, data) => {
|
||||
|
||||
const response = await fetch(url, {
|
||||
@@ -31,6 +46,9 @@ export default function ChangeUsername(props) {
|
||||
const text = await response.text()
|
||||
await setStatusText(text)
|
||||
setStatus(response.status)
|
||||
if (response.status === 200) {
|
||||
setTimeout(() => { logout() }, 2000)
|
||||
}
|
||||
setDisabled(false)
|
||||
setTimeout(() => { setStatus(null) }, 2000)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user