Skip to content

Commit

Permalink
Merge pull request #877 from bcgov/development
Browse files Browse the repository at this point in the history
Test Deployment
  • Loading branch information
saravanpa-aot authored Jul 14, 2020
2 parents 09d70e5 + 2da0f19 commit 9c067cb
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 33 deletions.
20 changes: 10 additions & 10 deletions auth-web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion auth-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"moment": "^2.24.0",
"regenerator-runtime": "^0.13.3",
"register-service-worker": "^1.6.2",
"sbc-common-components": "^2.2.1",
"sbc-common-components": "^2.2.3",
"vue": "^2.6.11",
"vue-i18n": "^8.0.0",
"vue-property-decorator": "^8.3.0",
Expand Down
18 changes: 9 additions & 9 deletions auth-web/src/components/auth/mixins/NextPageMixin.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// You can declare a mixin as the same style as components.
<script lang="ts">
import { LoginSource, Pages, SessionStorageKeys } from '@/util/constants'
import { LoginSource, Pages, Role, SessionStorageKeys } from '@/util/constants'
import { Member, MembershipStatus, MembershipType, OrgStatus, Organization } from '@/models/Organization'
import { mapActions, mapMutations, mapState } from 'vuex'
import { AccountSettings } from '@/models/account-settings'
Expand Down Expand Up @@ -81,25 +81,25 @@ export default class NextPageMixin extends Vue {
}
return `/${nextStep}`
case LoginSource.BCEID:
let bceditNextStep = '/'
let bceidNextStep = '/'
// Redirect to TOS if no terms accepted
// for invited users , handle user profile
// Redirect to create team if no orgs
// Redirect to dashboard otherwise
if (!this.userProfile?.userTerms?.isTermsOfUseAccepted) {
bceditNextStep = Pages.USER_PROFILE_TERMS
bceidNextStep = Pages.USER_PROFILE_TERMS
} else if (!this.currentOrganization && !this.currentMembership) {
bceditNextStep = Pages.CREATE_NON_BCSC_ACCOUNT
bceidNextStep = Pages.CHOOSE_AUTH_METHOD
} else if (this.currentOrganization && this.currentOrganization.statusCode === OrgStatus.PendingAffidavitReview) {
bceditNextStep = `${Pages.PENDING_APPROVAL}/${this.currentAccountSettings?.label}`
bceidNextStep = `${Pages.PENDING_APPROVAL}/${this.currentAccountSettings?.label}`
} else if (this.currentOrganization && this.currentMembership.membershipStatus === MembershipStatus.Active) {
bceditNextStep = `${Pages.MAIN}/${this.currentOrganization.id}`
bceidNextStep = `${Pages.MAIN}/${this.currentOrganization.id}`
} else if (this.currentMembership.membershipStatus === MembershipStatus.Pending) {
bceditNextStep = `${Pages.PENDING_APPROVAL}/${this.currentAccountSettings?.label}`
bceidNextStep = `${Pages.PENDING_APPROVAL}/${this.currentAccountSettings?.label}`
} else {
bceditNextStep = `${Pages.MAIN}/${this.currentOrganization.id}`
bceidNextStep = `${Pages.MAIN}/${this.currentOrganization.id}`
}
return `/${bceditNextStep}`
return `/${bceidNextStep}`
default:
return `/${Pages.HOME}`
}
Expand Down
5 changes: 4 additions & 1 deletion auth-web/src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ export enum Role {
StaffAdmin = 'staff_admin',
StaffAdminBCOL = 'bcol_staff_admin',
AnonymousUser = 'anonymous_user',
Tester = 'tester'
Tester = 'tester',
AccountHolder = 'account_holder',
PublicUser = 'public_user'
}

export enum Pages {
USER_PROFILE = 'userprofile',
CREATE_ACCOUNT = 'setup-account',
CREATE_NON_BCSC_ACCOUNT = 'setup-non-bcsc-account',
CHOOSE_AUTH_METHOD = 'choose-authentication-method',
PENDING_APPROVAL = 'pendingapproval',
MAIN = 'account',
SIGNIN = 'signin',
Expand Down
22 changes: 18 additions & 4 deletions auth-web/src/views/auth/ChooseAuthMethodView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,20 @@
import { Component, Vue } from 'vue-property-decorator'
import { LoginSource, Pages, SessionStorageKeys } from '@/util/constants'
import ConfigHelper from '@/util/config-helper'
import { mapGetters } from 'vuex'
@Component({
name: 'Home',
components: {
computed: {
...mapGetters('auth', [
'isAuthenticated',
'currentLoginSource'
])
}
})
export default class ChooseAuthMethodView extends Vue {
private readonly isAuthenticated!: boolean
private readonly currentLoginSource!: string
private authType = ''
private selectBCSCAuth () {
Expand All @@ -119,7 +125,7 @@ export default class ChooseAuthMethodView extends Vue {
}
private goNext () {
// TODO might need to set some session variables
// TODO might need to set some session variables
switch (this.authType) {
case LoginSource.BCEID:
ConfigHelper.addToSession(SessionStorageKeys.ExtraProvincialUser, 'true')
Expand All @@ -128,7 +134,15 @@ export default class ChooseAuthMethodView extends Vue {
break
case LoginSource.BCSC:
ConfigHelper.addToSession(SessionStorageKeys.ExtraProvincialUser, 'false') // this flag shouldnt be used for bcsc users.still setting the right value
this.$router.push(`/signin/bcsc/${Pages.CREATE_ACCOUNT}`)
if (this.isAuthenticated) {
if (this.currentLoginSource === LoginSource.BCEID) {
this.$router.push(`/${Pages.SETUP_ACCOUNT_NON_BCSC}`)
} else {
this.$router.push(`/${Pages.CREATE_ACCOUNT}`)
}
} else {
this.$router.push(`/signin/bcsc/${Pages.CREATE_ACCOUNT}`)
}
break
}
}
Expand Down
13 changes: 5 additions & 8 deletions auth-web/src/views/auth/SigninView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,16 @@ export default class Signin extends Mixins(NextPageMixin) {
@Prop({ default: '' }) redirectUrl: string
@Prop({ default: '' }) redirectUrlLoginFail: string
private async authenticationComplete (isRedirectToCreateAccount = false) {
private async authenticationComplete () {
await this.loadUserInfo()
// Check if user is authenticated, and redirect according to specified redirect
// or fallback to default route for their login source
if (this.$store.getters['auth/isAuthenticated']) {
this.$root.$emit('signin-complete', () => {
// isRedirectToCreateAccount: if true, redirection already happend from sbc-common-components
if (!isRedirectToCreateAccount) {
if (this.redirectUrl) {
this.redirectTo(decodeURIComponent(CommonUtils.isUrl(this.redirectUrl) ? this.redirectUrl : `/${this.redirectUrl}`))
} else {
this.redirectTo(this.getNextPageUrl())
}
if (this.redirectUrl) {
this.redirectTo(decodeURIComponent(CommonUtils.isUrl(this.redirectUrl) ? this.redirectUrl : `/${this.redirectUrl}`))
} else {
this.redirectTo(this.getNextPageUrl())
}
})
}
Expand Down

0 comments on commit 9c067cb

Please sign in to comment.