Skip to content

Commit

Permalink
Merge pull request #99 from ymaheshwari1/feat/launchpad-login-using-url
Browse files Browse the repository at this point in the history
Improved: support to pass /api in the url when redirecting to apps
  • Loading branch information
ymaheshwari1 authored Apr 4, 2024
2 parents 8bc1ec6 + fd7aa25 commit 568aa86
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ export default defineComponent({
// Run the basic login flow when oms and token both are found in query
if (this.$route.query?.oms && this.$route.query?.token) {
if(this.authStore.getRedirectUrl) {
window.location.href = `${this.authStore.getRedirectUrl}?oms=${this.$route.query?.oms}&token=${this.$route.query?.token}`
const routeOms = this.$route.query?.oms as string
const omsUrl = routeOms.startsWith('http') ? routeOms.includes('/api') ? routeOms : `${routeOms}/api/` : routeOms
window.location.href = `${this.authStore.getRedirectUrl}?oms=${omsUrl}&token=${this.$route.query?.token}`
} else {
await this.basicLogin()
this.dismissLoader();
Expand Down Expand Up @@ -158,7 +160,8 @@ export default defineComponent({
// if a session is already active, login directly in the app
if (this.authStore.isAuthenticated) {
if(this.authStore.getRedirectUrl) {
window.location.href = `${this.authStore.getRedirectUrl}?oms=${this.authStore.oms}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}`
const omsUrl = this.authStore.oms.startsWith('http') ? this.authStore.oms.includes('/api') ? this.authStore.oms : `${this.authStore.oms}/api/` : this.authStore.oms
window.location.href = `${this.authStore.getRedirectUrl}?oms=${omsUrl}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}`
} else {
this.router.push('/')
}
Expand Down Expand Up @@ -247,7 +250,8 @@ export default defineComponent({
try {
await this.authStore.login(username.trim(), password)
if (this.authStore.getRedirectUrl) {
window.location.href = `${this.authStore.getRedirectUrl}?oms=${this.authStore.oms}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}`
const omsUrl = this.authStore.oms.startsWith('http') ? this.authStore.oms.includes('/api') ? this.authStore.oms : `${this.authStore.oms}/api/` : this.authStore.oms
window.location.href = `${this.authStore.getRedirectUrl}?oms=${omsUrl}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}`
} else {
// All the failure cases are handled in action, if then block is executing, login is successful
this.username = ''
Expand All @@ -263,7 +267,8 @@ export default defineComponent({
const { token, expirationTime } = this.$route.query as any
await this.authStore.samlLogin(token, expirationTime)
if (this.authStore.getRedirectUrl) {
window.location.href = `${this.authStore.getRedirectUrl}?oms=${this.authStore.oms}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}`
const omsUrl = this.authStore.oms.startsWith('http') ? this.authStore.oms.includes('/api') ? this.authStore.oms : `${this.authStore.oms}/api/` : this.authStore.oms
window.location.href = `${this.authStore.getRedirectUrl}?oms=${omsUrl}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}`
} else {
this.router.push('/')
}
Expand Down

0 comments on commit 568aa86

Please sign in to comment.