Skip to content

Commit

Permalink
init openlogin instance
Browse files Browse the repository at this point in the history
fix not inited bug
  • Loading branch information
BboyStatix committed Jan 9, 2024
1 parent 63c1c05 commit d6d9871
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions examples/vue-example/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export default defineComponent({
await this.openloginInstance.init();
}
if (this.openloginInstance.privKey || this.openloginInstance.state.factorKey) {
this.privKey = this.openloginInstance.privKey || this.openloginInstance.state.factorKey as string;
this.privKey = this.openloginInstance.privKey || (this.openloginInstance.state.factorKey as string);
await this.setProvider(this.privKey);
}
this.loading = false;
Expand Down Expand Up @@ -234,14 +234,15 @@ export default defineComponent({
}
: undefined,
});
op.init();
return op;
},
showEmailFlow(): boolean {
return this.selectedLoginProvider === LOGIN_PROVIDER.EMAIL_PASSWORDLESS;
},
isMFAEnabled(): boolean {
return this.openloginInstance.state.userInfo?.isMfaEnabled || false;
}
},
},
methods: {
async login() {
Expand Down Expand Up @@ -311,7 +312,7 @@ export default defineComponent({
async setProvider(privKey: string) {
if (this.useMpc) {
const { factorKey, tssPubKey, tssShareIndex, userInfo, tssShare, tssNonce, signatures } = this.openloginInstance.state;
const { factorKey, tssPubKey, tssShareIndex, userInfo, tssShare, tssNonce, signatures } = this.openloginInstance.state;
this.ethereumPrivateKeyProvider = new EthMpcPrivKeyProvider({
config: {
chainConfig: {
Expand Down Expand Up @@ -408,7 +409,7 @@ export default defineComponent({
async enableMFA() {
if (!this.openloginInstance || !this.openloginInstance.sessionId) {
throw new Error("User not logged in")
throw new Error("User not logged in");
}
await this.openloginInstance.enableMFA({
loginProvider: this.selectedLoginProvider,
Expand All @@ -421,14 +422,14 @@ export default defineComponent({
async manageMFA() {
if (!this.openloginInstance || !this.openloginInstance.sessionId) {
throw new Error("User not logged in")
throw new Error("User not logged in");
}
await this.openloginInstance.manageMFA({
loginProvider: this.selectedLoginProvider,
extraLoginOptions: {
login_hint: this.openloginInstance.getUserInfo().email,
flow_type: this.emailFlowType,
}
},
});
},
Expand Down

0 comments on commit d6d9871

Please sign in to comment.