1
0

feat: persist link share auth rule in url hash

This allows sharing links to a task directly. We're using hashes instead
of query parameters because hash values are usually not logged in access
logs.

With this change, when a user uses a link share, the link share hash
will be appended to all urls while browsing. When a link share hash is
encountered in the current url and the user is not authenticated, they
will be redirected to the link share auth page, get authenticated and
then get redirected to whatever url they were previously on.
This commit is contained in:
kolaente
2023-04-01 12:14:52 +02:00
parent 25f9f5dceb
commit f68bb2625e
3 changed files with 67 additions and 9 deletions

View File

@ -5,16 +5,24 @@ export function useRedirectToLastVisited() {
const router = useRouter()
function redirectIfSaved() {
function getRedirectRoute() {
const last = getLastVisited()
if (last !== null) {
router.push({
clearLastVisited()
return {
name: last.name,
params: last.params,
query: last.query,
})
clearLastVisited()
return
}
}
return null
}
function redirectIfSaved() {
const lastRoute = getRedirectRoute()
if (lastRoute) {
router.push(lastRoute)
}
router.push({name: 'home'})
@ -22,5 +30,6 @@ export function useRedirectToLastVisited() {
return {
redirectIfSaved,
getRedirectRoute,
}
}