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:
@ -43,9 +43,11 @@ import {PROJECT_VIEWS, type ProjectView} from '@/types/ProjectView'
|
||||
|
||||
import {useBaseStore} from '@/stores/base'
|
||||
import {useAuthStore} from '@/stores/auth'
|
||||
import {useRedirectToLastVisited} from '@/composables/useRedirectToLastVisited'
|
||||
|
||||
const {t} = useI18n({useScope: 'global'})
|
||||
useTitle(t('sharing.authenticating'))
|
||||
const {getRedirectRoute} = useRedirectToLastVisited()
|
||||
|
||||
function useAuth() {
|
||||
const baseStore = useBaseStore()
|
||||
@ -59,6 +61,7 @@ function useAuth() {
|
||||
const password = ref('')
|
||||
|
||||
const authLinkShare = computed(() => authStore.authLinkShare)
|
||||
const linkShareHashPrefix = '#linkshare='
|
||||
|
||||
async function authenticate() {
|
||||
authenticateWithPassword.value = false
|
||||
@ -87,7 +90,22 @@ function useAuth() {
|
||||
? route.query.view
|
||||
: 'list'
|
||||
|
||||
router.push({name: `project.${view}`, params: {projectId}})
|
||||
const hash = linkShareHashPrefix + route.params.share
|
||||
|
||||
const last = getRedirectRoute()
|
||||
if (last) {
|
||||
router.push({
|
||||
...last,
|
||||
hash,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
router.push({
|
||||
name: `project.${view}`,
|
||||
params: {projectId},
|
||||
hash,
|
||||
})
|
||||
} catch (e: any) {
|
||||
if (e.response?.data?.code === 13001) {
|
||||
authenticateWithPassword.value = true
|
||||
|
Reference in New Issue
Block a user