Skip to content

Commit

Permalink
Revert "APP-479 Fix MockLogins"
Browse files Browse the repository at this point in the history
This reverts commit e292fc4.
  • Loading branch information
codeho authored and Thorsten Schau committed Aug 25, 2023
1 parent e292fc4 commit f53517b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 48 deletions.
34 changes: 6 additions & 28 deletions shell/src/dapps/o-onboarding/processes/loginWithTorus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ import HtmlViewer from "../../../../../packages/o-editors/src/HtmlViewer.svelte"
import { PlatformEvent } from "@o-platform/o-events/dist/platformEvent";
import { show } from "@o-platform/o-process/dist/actions/show";
import ErrorView from "../../../shared/atoms/Error.svelte";
import { Web3Auth, GetWeb3AuthResult } from "../../../shared/web3AuthNoModal";
import { Web3Auth } from "../../../shared/web3AuthNoModal";
import { FindInvitationCreatorDocument, Profile, QueryFindInvitationCreatorArgs } from "../../../shared/api/data/types";
import { ApiClient } from "../../../shared/apiConnection";
import { AvataarGenerator } from "../../../shared/avataarGenerator";
import { setWindowLastError } from "../../../shared/processes/actions/setWindowLastError";
import { OpenloginUserInfo } from "@web3auth/openlogin-adapter";

import { Environment } from "../../../shared/environment";

Expand Down Expand Up @@ -133,11 +132,11 @@ const processDefinition = (processId: string) =>
onDone: [
{
cond: (context) => Environment.useMockLogin === true,
target: "#useMockProfile",
target: "useMockProfile",
},
{
cond: (context) => context.data.accountAddress === undefined,
target: "#chooseFlow",
target: "chooseFlow",
},
{
cond: (context) => context.data.accountAddress !== undefined,
Expand Down Expand Up @@ -198,30 +197,9 @@ const processDefinition = (processId: string) =>
src: async (context) => {
const webauth = new Web3Auth();
await webauth.init();
let privateKey: { privKey: any } = undefined;
let userInfo: OpenloginUserInfo;

const mockProfile = Environment.getTestProfile(context.data.useMockProfileIndex);

if (mockProfile) {
privateKey = {
privKey: mockProfile.privateKey,
};

const openLogin = <GetWeb3AuthResult>{
async getUserInfo(): Promise<Partial<OpenloginUserInfo>> {
delete mockProfile.privateKey;
return mockProfile;
},
};

userInfo = <OpenloginUserInfo>await openLogin.getUserInfo();
} else {
await webauth.login("mock", context.data.useMockProfileIndex);
privateKey = await webauth.getPrivateKey();
userInfo = await webauth.getUserInfo(context.data.useMockProfileIndex);
}

await webauth.login("mock", context.data.useMockProfileIndex);
const privateKey = await webauth.getPrivateKey();
const userInfo = await webauth.getUserInfo(context.data.useMockProfileIndex);
return {
privateKey: privateKey.privKey,
userInfo: userInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ const options = {
enableTime: false,
weekNumbers: true,
altInput: true,
minDate: "1900-01-01",
maxDate: "today",
altFormat: "F j, Y",
time_24hr: true,
onChange(selectedDates, dateStr) {
Expand Down Expand Up @@ -263,7 +261,7 @@ const options = {
{#if $inviteUrl}
<span class="text-sm grow text-success">{$_("dapps.o-homepage.components.survey.userDataCollection.inviteValid")}</span>
{:else}
<button class="px-8 overflow-hidden text-lg transition-all transform grow btn btn-primary" on:click="{() => handleClick('openQRCode')}" disabled="{$inviteUrl}">
<button class="px-8 overflow-hidden transition-all transform grow btn btn-primary text-lg" on:click="{() => handleClick('openQRCode')}" disabled="{$inviteUrl}">
{$_("dapps.o-homepage.components.survey.button.scanInviteNow")}
</button>
{/if}
Expand All @@ -289,13 +287,13 @@ const options = {
{/if}
<div class="flex flex-row justify-between w-full pr-4 mt-10 mb-5 text-center">
<div>
<button class="relative px-8 overflow-hidden text-lg transition-all transform btn bg-cpurple border-warning text-warning" on:click="{() => handleClick('back')}">
<button class="relative px-8 overflow-hidden transition-all transform btn bg-cpurple border-warning text-warning text-lg" on:click="{() => handleClick('back')}">
{$_("dapps.o-homepage.components.survey.button.goBack")}</button>
</div>
<div>
{#if $myForm.dirty}
<button
class="relative px-8 overflow-hidden text-lg transition-all transform btn btn-primary bg-primary text-cpurple"
class="relative px-8 overflow-hidden transition-all transform btn btn-primary bg-primary text-cpurple text-lg"
on:click="{() => handleClick('next')}"
disabled="{!$myForm.valid}">
{$_("dapps.o-homepage.components.survey.button.next")}</button>
Expand Down
17 changes: 2 additions & 15 deletions shell/src/shared/web3AuthNoModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,10 @@ export class Web3Auth {
console.log("idToken: ", idToken);
};

getUserInfo = async (mockprofileIndex: number = undefined) => {
getUserInfo = async (mockprofileIndex: number = 0) => {
console.log("Mockindes:", mockprofileIndex);
if (Environment.useMockLogin) {
let user: Partial<OpenloginUserInfo>;
if (mockprofileIndex) {
user = Environment.getTestProfile(mockprofileIndex);
} else {
user = {
email: "[email protected]",
name: "Oauth profile name",
typeOfLogin: "google",
profileImage: "https://some.url.to.somewhere",
aggregateVerifier: "not-verified",
verifier: "not-verified",
verifierId: "not-verified",
};
}
const user: Partial<OpenloginUserInfo> = Environment.getTestProfile(mockprofileIndex);
return user as OpenloginUserInfo;
} else {
if (!this.web3auth) {
Expand Down

0 comments on commit f53517b

Please sign in to comment.