-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add programmatic redirect to dashbord or freshdesk from login page
- Loading branch information
Showing
2 changed files
with
68 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,26 @@ | ||
import Route from '@ember/routing/route'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default class LoginRoute extends Route {} | ||
export default class LoginRoute extends Route { | ||
@service session; | ||
@service router; | ||
@service store; | ||
@service('browser/window') window; | ||
|
||
async beforeModel(transition) { | ||
if (this.session.isAuthenticated) { | ||
const { queryParams } = transition.to; | ||
|
||
if (queryParams?.next) { | ||
const userId = this.session.data.authenticated.user_id; | ||
const user = await this.store.findRecord('user', userId); | ||
const username = user.username; | ||
|
||
const nextURL = `${queryParams.next}&username=${username}`; | ||
this.window.location.assign(nextURL); | ||
} else { | ||
this.router.transitionTo('authenticated.projects'); | ||
} | ||
} | ||
} | ||
} |