useRedirect.ts 712 B

12345678910111213141516171819202122232425
  1. import UrlUtils from '~/services/utils/urlUtils'
  2. export const useRedirect = () => {
  3. const runtimeConfig = useRuntimeConfig()
  4. const redirectToLogout = () => {
  5. if (!runtimeConfig.baseUrlAdminLegacy) {
  6. throw new Error('Configuration error : no redirection target')
  7. }
  8. navigateTo(UrlUtils.join(runtimeConfig.baseUrlAdminLegacy, '#/logout'), {
  9. external: true,
  10. })
  11. }
  12. const redirectToHome = () => {
  13. if (!runtimeConfig.baseUrlAdminLegacy) {
  14. throw new Error('Configuration error : no redirection target')
  15. }
  16. navigateTo(UrlUtils.join(runtimeConfig.baseUrlAdminLegacy, '#/dashboard'), {
  17. external: true,
  18. })
  19. }
  20. return { redirectToLogout, redirectToHome }
  21. }