#238: Remove hash from URL with JS instead of full redirect
This commit is contained in:
parent
bdb6dd0d54
commit
85d64f23eb
@ -60,18 +60,17 @@ async function newPasswordFunc() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @TODO: #238, this wont work if we redirect to the login page
|
|
||||||
* Find a way to just "close" this screen instead of redirecting
|
|
||||||
*/
|
|
||||||
gameStore.addNotification({
|
gameStore.addNotification({
|
||||||
title: 'Success',
|
title: 'Success',
|
||||||
message: 'Password changed successfully'
|
message: 'Password changed successfully'
|
||||||
})
|
})
|
||||||
window.location.href = '/'
|
|
||||||
|
window.history.replaceState(null, '', window.location.pathname)
|
||||||
|
emit('switchToLogin')
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelNewPassword() {
|
function cancelNewPassword() {
|
||||||
window.location.href = '/'
|
window.history.replaceState(null, '', windowlocation.pathname)
|
||||||
|
emit('switchToLogin')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
<LoginForm v-if="currentForm === 'login' && !doesUrlHaveToken" @openResetPasswordModal="() => (isPasswordResetFormShown = true)" @switchToRegister="currentForm = 'register'" />
|
<LoginForm v-if="currentForm === 'login' && !doesUrlHaveToken" @openResetPasswordModal="() => (isPasswordResetFormShown = true)" @switchToRegister="currentForm = 'register'" />
|
||||||
|
|
||||||
<!-- Register Form -->
|
<!-- Register Form -->
|
||||||
<RegisterForm v-if="currentForm === 'register' && !doesUrlHaveToken" @switchToLogin="currentForm = 'login'" />
|
<RegisterForm v-if="currentForm === 'register' && !doesUrlHaveToken" @switchToLogin="switchToLogin" />
|
||||||
|
|
||||||
<!-- New Password Form -->
|
<!-- New Password Form -->
|
||||||
<NewPasswordForm v-if="doesUrlHaveToken" @switchToLogin="currentForm = 'login'" />
|
<NewPasswordForm v-if="doesUrlHaveToken" @switchToLogin="switchToLogin" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -35,11 +35,16 @@ import NewPasswordForm from '@/components/login/NewPasswordForm.vue'
|
|||||||
import ResetPassword from '@/components/login/ResetPasswordModal.vue'
|
import ResetPassword from '@/components/login/ResetPasswordModal.vue'
|
||||||
|
|
||||||
const isPasswordResetFormShown = ref(false)
|
const isPasswordResetFormShown = ref(false)
|
||||||
const doesUrlHaveToken = window.location.hash.includes('#')
|
const doesUrlHaveToken = ref(window.location.hash !== '')
|
||||||
|
|
||||||
const gameStore = useGameStore()
|
const gameStore = useGameStore()
|
||||||
const currentForm = ref('login')
|
const currentForm = ref('login')
|
||||||
|
|
||||||
|
function switchToLogin() {
|
||||||
|
currentForm.value = 'login'
|
||||||
|
doesUrlHaveToken.value = false
|
||||||
|
}
|
||||||
|
|
||||||
// automatic login because of development
|
// automatic login because of development
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const token = useCookies().get('token')
|
const token = useCookies().get('token')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user