+
+ // Track previous url
+ this.currentUrl = this.router.url
+ router.events.subscribe(event => {
+ if (event instanceof NavigationEnd) {
+ this.previousUrl = this.currentUrl
+ this.currentUrl = event.url
+ }
+ })
+ }
+
+ redirectToPreviousRoute () {
+ const exceptions = [
+ '/verify-account',
+ '/reset-password'
+ ]
+
+ if (this.previousUrl) {
+ const isException = exceptions.find(e => this.previousUrl.startsWith(e))
+ if (!isException) return this.router.navigateByUrl(this.previousUrl)
+ }
+
+ return this.redirectToHomepage()