Skip to content

Commit

Permalink
Implemented: support for maarg login in ofbiz apps (preorder-293)
Browse files Browse the repository at this point in the history
  • Loading branch information
amansinghbais committed Aug 6, 2024
1 parent 473c0d7 commit 4d012d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ VUE_APP_I18N_FALLBACK_LOCALE=en
VUE_APP_LOCALES={"en": "English", "ja": "日本語", "es": "Español"}
VUE_APP_CURRENCY_FORMATS={"en": {"currency": {"style": "currency","currency": "USD"}}, "ja": {"currency": {"style": "currency", "currency": "JPY"}}, "es": {"currency": {"style": "currency","currency": "ESP"}}}
VUE_APP_DEFAULT_ALIAS=
VUE_APP_MAARG_LOGIN=["atp", "company", "order-routing"]
VUE_APP_MAARG_LOGIN=["atp", "company", "order-routing"]
VUE_APP_MAARG_LOGIN_REQUIRED=["preorder"]
7 changes: 6 additions & 1 deletion src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ const isMaargLogin = (handle: string) => {
return maargLoginApps.some((appName: string) => handle.includes(appName))
}

export { isMaargLogin, showToast }
const isMaargLoginRequired = (handle: string) => {
const maargOmsRequiredApps = JSON.parse(process.env.VUE_APP_MAARG_LOGIN_REQUIRED ? process.env.VUE_APP_MAARG_LOGIN_REQUIRED : [])
return maargOmsRequiredApps.some((appName: string) => handle.includes(appName))
}

export { isMaargLogin, isMaargLoginRequired, showToast }
9 changes: 7 additions & 2 deletions src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import Logo from '@/components/Logo.vue';
import { arrowForwardOutline, gridOutline } from 'ionicons/icons'
import { UserService } from "@/services/UserService";
import { translate } from "@/i18n";
import { isMaargLogin, showToast } from "@/util";
import { isMaargLogin, isMaargLoginRequired, showToast } from "@/util";
import { hasError } from "@hotwax/oms-api";
export default defineComponent({
Expand Down Expand Up @@ -293,6 +293,7 @@ export default defineComponent({
},
generateRedirectionLink() {
let omsUrl = ''
let omsRedirectionUrl = ''
if(isMaargLogin(this.authStore.getRedirectUrl)) {
if(this.authStore.getMaargOms) omsUrl = this.authStore.getMaargOms
else {
Expand All @@ -302,8 +303,12 @@ export default defineComponent({
}
}
if(isMaargLoginRequired(this.authStore.getRedirectUrl) && this.authStore.getMaargOms) {
omsRedirectionUrl = this.authStore.getMaargOms
}
omsUrl = omsUrl ? 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}${isMaargLogin(this.authStore.getRedirectUrl) ? '&omsRedirectionUrl=' + this.authStore.oms : ''}`
window.location.href = `${this.authStore.getRedirectUrl}?oms=${omsUrl}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}${omsRedirectionUrl ? '&omsRedirectionUrl=' + omsRedirectionUrl : ''}`
}
},
setup () {
Expand Down

0 comments on commit 4d012d1

Please sign in to comment.