useRedirect.ts 735 B

123456789101112131415161718192021
  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'), {external: true})
  9. }
  10. const redirectToHome = () => {
  11. if (!runtimeConfig.baseUrlAdminLegacy) {
  12. throw new Error('Configuration error : no redirection target')
  13. }
  14. navigateTo(UrlUtils.join(runtimeConfig.baseUrlAdminLegacy, '#/dashboard'), {external: true})
  15. }
  16. return { redirectToLogout, redirectToHome }
  17. }