]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/core/routing/redirect.service.ts
Add URL redirection support for external auth
[github/Chocobozzz/PeerTube.git] / client / src / app / core / routing / redirect.service.ts
index 198332b00bdd925363b576d541627549b9251e6a..d4cb0436e54324b2b609805c5094ed857833966b 100644 (file)
@@ -42,22 +42,29 @@ export class RedirectService {
     return this.defaultRoute
   }
 
-
   getDefaultTrendingAlgorithm () {
     return this.defaultTrendingAlgorithm
   }
 
-  redirectToPreviousRoute () {
+  getPreviousUrl () {
+    return this.previousUrl
+  }
+
+  redirectToPreviousRoute (fallbackRoute?: string) {
     const exceptions = [
       '/verify-account',
       '/reset-password'
     ]
 
-    if (this.previousUrl) {
+    if (this.previousUrl && this.previousUrl !== '/') {
       const isException = exceptions.find(e => this.previousUrl.startsWith(e))
       if (!isException) return this.router.navigateByUrl(this.previousUrl)
     }
 
+    if (fallbackRoute) {
+      return this.router.navigateByUrl(fallbackRoute)
+    }
+
     return this.redirectToHomepage()
   }