]> 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 17d9d1358b3a0db443a0f6b5a06eba3102cabfec..d4cb0436e54324b2b609805c5094ed857833966b 100644 (file)
@@ -46,17 +46,25 @@ export class RedirectService {
     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()
   }