Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues/passing metaverse url login register #43

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25,768 changes: 12,867 additions & 12,901 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"axios": "^0.21.4",
"core-js": "^3.19.1",
"quasar": "^2.3.3",
"vue": "^3.2.29",
"vue-router": "^4.0.12",
"vuex": "^4.0.1"
},
"devDependencies": {
Expand Down
91 changes: 76 additions & 15 deletions src/components/components/login/MetaverseLogin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@
-->

<template>
<q-form
@submit="onSubmit"
@reset="onReset"
class="q-gutter-md"
>
<q-form @submit="onSubmit" @reset="onReset" class="q-gutter-md">
<q-input
v-model="username"
filled
label="Username"
hint="Enter your username."
lazy-rules
:rules="[ val => val && val.length > 0 || 'Please enter a username.']"
:rules="[
(val) => (val && val.length > 0) || 'Please enter a username.',
]"
/>

<q-input
Expand All @@ -30,7 +28,9 @@
:type="showPassword ? 'text' : 'password'"
hint="Enter your password."
lazy-rules
:rules="[ val => val && val.length > 0 || 'Please enter a password.']"
:rules="[
(val) => (val && val.length > 0) || 'Please enter a password.',
]"
>
<template v-slot:append>
<q-icon
Expand All @@ -42,31 +42,92 @@
</q-input>

<div align="right">
<q-btn label="Reset" type="reset" color="primary" flat class="q-mr-sm" />
<q-btn label="Login" type="submit" color="primary"/>
<q-btn
label="Reset"
type="reset"
color="primary"
flat
class="q-mr-sm"
/>
<q-btn label="Login" type="submit" color="primary" />
</div>
</q-form>

<q-expansion-item
v-model="metaverseServerSettingExpansion"
expand-icon="language"
label="Advanced"
expand-icon-class="text-red"
header-class="clean-header"
>
<q-card class="no-padding">
<q-card-section class="no-padding">
<q-input
v-model="metaverseServerSetting"
label="Metaverse Server"
>
<template v-slot:before>
<q-icon name="language" size="18px" color="primary" />
</template>

<template v-slot:append>
<q-icon
name="save"
size="18px"
color="primary"
@click="
metaverseServerStore = metaverseServerSetting;
metaverseServerSettingExpansion = false;
"
class="cursor-pointer"
/>
</template>
</q-input>
</q-card-section>
</q-card>
</q-expansion-item>
</template>

<script lang="ts">
import { defineComponent } from "vue";
import { Account } from "@Modules/account";
import { Utility } from "@Modules/utility";

export default defineComponent({
name: "MetaverseLogin",

emits: ["closeDialog"],

data: () => ({
username: "",
password: "",
showPassword: false
}),
data: function() {
return {
username: "",
password: "",
showPassword: false,
metaverseServerSettingExpansion: false,
metaverseServerSetting: this.$store.state.metaverse.server
};
},
computed: {
metaverseServerStore: {
get() {
return this.$store.state.metaverse.server;
},
async set(newValue: string) {
await Utility.metaverseConnectionSetup(
newValue
);
}
}
},

methods: {
async onSubmit() {
try {
const loginResponse = await Account.login(this.username, this.password);
const loginResponse = await Account.login(
this.username,
this.password,
this.$store.state.metaverse.server
);

if (loginResponse) {
this.$q.notify({
Expand Down
72 changes: 63 additions & 9 deletions src/components/components/login/MetaverseRegister.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,85 @@
<q-btn label="Register" type="submit" color="primary"/>
</div>
</q-form>
{{$store.state.metaverse.server}}

<q-expansion-item
v-model="metaverseServerSettingExpansion"
expand-icon="language"
label="Advanced"
expand-icon-class="text-red"
header-class="clean-header"
>
<q-card class="no-padding">
<q-card-section class="no-padding">
<q-input
v-model="metaverseServerSetting"
label="Metaverse Server"
>
<template v-slot:before>
<q-icon name="language" size="18px" color="primary" />
</template>

<template v-slot:append>
<q-icon
name="save"
size="18px"
color="primary"
@click="
metaverseServerStore = metaverseServerSetting;
metaverseServerSettingExpansion = false;
"
class="cursor-pointer"
/>
</template>
</q-input>
</q-card-section>
</q-card>
</q-expansion-item>
</template>

<script lang="ts">
import { defineComponent } from "vue";
import { useQuasar } from "quasar";
import { Utility } from "@Modules/utility";

import { Account } from "@Modules/account";

export default defineComponent({
name: "MetaverseRegister",

data: () => ({
username: "",
email: "",
password: "",
confirmPassword: "",
showPassword: false,
showConfirmPassword: false
}),
data: function() {
return {
username: "",
email: "",
password: "",
confirmPassword: "",
showPassword: false,
showConfirmPassword: false,
metaverseServerSettingExpansion: false,
metaverseServerSetting: this.$store.state.metaverse.server
};
},

computed: {
metaverseServerStore: {
get() {
return this.$store.state.metaverse.server;
},
async set(newValue: string) {
await Utility.metaverseConnectionSetup(
newValue
);
}
}
},

methods: {
async onSubmit() {
const $q = useQuasar();
try {
const awaiting = await Account.createAccount(this.username, this.password, this.email);
const awaiting = await Account.createAccount(this.username, this.password,
this.email, this.$store.state.metaverse.server);
const result = { // TODO: temp to replace code above
data: {
accountWaitingVerification: awaiting
Expand Down
7 changes: 5 additions & 2 deletions src/components/dialogs/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@

<q-tab-panels v-model="tab" animated>
<q-tab-panel name="metaverseLogin">
<MetaverseLogin @closeDialog="$emit('closeDialog', 'close')"></MetaverseLogin>
<MetaverseLogin
@closeDialog="$emit('closeDialog', 'close')"></MetaverseLogin>
</q-tab-panel>

<q-tab-panel name="metaverseRegister">
<MetaverseRegister @register-success="onMetaverseRegister"></MetaverseRegister>
<MetaverseRegister
@register-success="onMetaverseRegister"></MetaverseRegister>
</q-tab-panel>
</q-tab-panels>
</q-card-section>
Expand All @@ -44,6 +46,7 @@
<script lang="ts">
import { defineComponent } from "vue";


// eslint-disable-next-line @typescript-eslint/no-unused-vars
import Log from "@Modules/debugging/log";

Expand Down
8 changes: 4 additions & 4 deletions src/modules/account/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const Account = {
* @param {string} pPassword Password of user to login
* @returns 'true' if login succeeded.
*/
async login(pUsername: string, pPassword: string): Promise<boolean> {
async login(pUsername: string, pPassword: string, pMetaverseUrl?: string): Promise<boolean> {
Gigabyte5671 marked this conversation as resolved.
Show resolved Hide resolved
if (MetaverseMgr.ActiveMetaverse?.isConnected && !Account.isLoggedIn) {
try {
// Log.debug(Log.types.ACCOUNT, `Login: ${pUsername}`);
Expand All @@ -86,7 +86,7 @@ export const Account = {
params.append("username", pUsername);
params.append("password", pPassword);

const loginUrl = buildUrl(OAuthTokenAPI);
const loginUrl = buildUrl(OAuthTokenAPI, pMetaverseUrl);
const resp = await axios.post(loginUrl, params);
if (resp.data) {
const maybeError = resp.data as unknown as OAuthTokenError;
Expand Down Expand Up @@ -162,14 +162,14 @@ export const Account = {
}
},

async createAccount(pUsername: string, pPassword: string, pEmail: string): Promise<boolean> {
async createAccount(pUsername: string, pPassword: string, pEmail: string, pMetaverseUrl?: string): Promise<boolean> {
const req = {
username: pUsername,
password: pPassword,
email: pEmail
} as PostUsersReq;
try {
const resp = await doAPIPost(PostUsersAPI, req) as PostUsersResp;
const resp = await doAPIPost(PostUsersAPI, req, pMetaverseUrl) as PostUsersResp;
Account.accountName = resp.username;
Account.id = resp.accountId;

Expand Down
4 changes: 2 additions & 2 deletions src/modules/metaverse/metaverseOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export async function doAPIGet(pAPIUrl: string, pMetaverseUrl?: string): Promise
throw new Error(errorString);
}

export async function doAPIPost(pAPIUrl: string, pBody: KeyedCollection): Promise<unknown> {
const accessUrl = buildUrl(pAPIUrl);
export async function doAPIPost(pAPIUrl: string, pBody: KeyedCollection, pMetaverseUrl?: string): Promise<unknown> {
const accessUrl = buildUrl(pAPIUrl, pMetaverseUrl);
try {
const resp = await axios.post(accessUrl, pBody, buildRequestConfig());
const response = resp.data as unknown as APIResponse;
Expand Down
1 change: 1 addition & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ export const Store = createStore<IRootState>({
},
// Example action. Any script should be calling the Metavsere component directly
async [Actions.SET_METAVERSE_URL](pContext: ActionContext<IRootState, IRootState>, pUrl: string): Promise<void> {
console.log("pUrl", pUrl);
await MetaverseMgr.ActiveMetaverse.setMetaverseUrl(pUrl);
}
},
Expand Down