Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 3x 3x 291x 291x 252x 252x 17x 17x | /**
* Where to go after signing in or up. Only a page of a public space is
* accepted: its join page (UC-SPACE-004.1 AC-3: Bob comes back to the form he
* left), its home or another of its pages (UC-SPACE-015.1 AC-3: the "Sign in"
* button of the space's header), so the `redirect` query can never send a user
* to another site or an arbitrary page.
*/
import type { LocationQuery } from 'vue-router'
const JOIN_PAGE = /^\/space\/([a-z0-9-]{1,100})\/join$/
const SPACE_PAGE = /^\/space\/[a-z0-9-]{1,100}(\/[a-z0-9-]{1,50})?$/
/** The `redirect` query when it names a page of a space, else undefined */
export function authRedirect(query: LocationQuery): string | undefined {
const value = query.redirect
return typeof value === 'string' && SPACE_PAGE.test(value) ? value : undefined
}
/** The query to carry the redirect along to the other auth page */
export function redirectQuery(query: LocationQuery): { redirect?: string } {
const redirect = authRedirect(query)
return redirect ? { redirect } : {}
}
/**
* The slug of the flow whose join page the user came from, else undefined:
* sent with the sign-up so its verification email shows that flow
* (UC-SPACE-008.1)
*/
export function joinSlug(query: LocationQuery): string | undefined {
const redirect = authRedirect(query)
return redirect?.match(JOIN_PAGE)?.[1]
}
|