Skip to content

Commit

Permalink
Merge pull request #25 from stc-community/revert-24-feat-auth
Browse files Browse the repository at this point in the history
Revert "Add user account authorized function"
  • Loading branch information
rovast authored Jul 13, 2023
2 parents 6063cdc + f8bb010 commit 556d750
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 505 deletions.
5 changes: 0 additions & 5 deletions locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,3 @@ wasm:
Capabilities: Capabilities

"New Actor": New Actor

user:
"modal title": Join CloudX3
"modal description": Once you click on "Join CloudX3," the platform will generate user information for you, which will be used for subsequent resource creation and management.
"join now": Join Now
5 changes: 0 additions & 5 deletions locales/zh-CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,3 @@ wasm:
Capabilities: 能力声明

"New Actor": 创建Actor

user:
"modal title": 加入 CloudX3
"modal description": 点击加入 CloudX3 后,平台会为你生成用户信息,用于后续的资源创建和管理
"join now": 现在加入
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
"animate.css": "^4.1.1",
"apexcharts": "^3.37.1",
"axios": "^1.2.1",
"crypto-js": "^4.1.1",
"daisyui": "^3.2.1",
"daisyui": "^2.50.2",
"dayjs": "^1.11.6",
"ethers": "^6.1.0",
"js-base64": "^3.7.5",
Expand Down
76 changes: 44 additions & 32 deletions pnpm-lock.yaml

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

50 changes: 0 additions & 50 deletions src/components/Modal/account.bak.vue

This file was deleted.

54 changes: 22 additions & 32 deletions src/components/Modal/account.vue
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
<script setup lang="ts">
import { useAccountStore } from "@/store/modules/account";
import { ref } from "vue";
import { useLang } from "@/hooks/useLang";
const { t } = useLang();
import { getNewNostrPrivateKey } from "@/utils/shared";
import { getPublicKey } from "nostr-tools";
import { getUserHubContract } from "@/utils/contract/user-hub";
import { handleEtherError, encrypt } from "@/utils/shared";
const privateKey = ref("");
const loading = ref(false);
const handleSubmit = async () => {
privateKey.value = getNewNostrPrivateKey();
const publicKey = getPublicKey(privateKey.value);
defineOptions({
name: "account"
});
const contract = await getUserHubContract();
try {
loading.value = true;
console.log("contract.registerUser", publicKey, encrypt(privateKey.value));
const transaction = await contract.registerUser(
publicKey,
encrypt(privateKey.value)
);
const privateKey = ref("");
const accountStore = useAccountStore();
await transaction.wait();
const handleSubmit = () => {
const err = accountStore.savePrivateKey(privateKey.value);
if (err) {
window.alert(err);
} else {
window.location.reload();
} catch (e) {
loading.value = false;
handleEtherError(e);
}
};
</script>
Expand All @@ -43,17 +31,19 @@ const handleSubmit = async () => {
>✕</label
>

<h3 class="font-bold text-lg">{{ t("user.modal title") }}</h3>
<p class="py-4">{{ t("user.modal description") }}</p>
<h3 class="font-bold text-lg">{{ t("common.input private key") }}</h3>
<p class="py-4">
<input
v-model="privateKey"
type="text"
:placeholder="t('common.input private key here')"
class="input input-bordered input-primary w-full"
/>
</p>
<div class="modal-action">
<label
class="btn btn-primary"
:class="{ 'btn-disabled': loading }"
@click="handleSubmit"
<label for="key-modal" class="btn btn-primary" @click="handleSubmit"
>{{ t("common.yay") }}!</label
>
<span v-if="loading" class="loading loading-spinner" />
<span>{{ t("user.join now") }}!</span>
</label>
</div>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ getServerConfig(app).then(async config => {
setupStore(app);

app.use(useI18n);
app.mount("#app");

// get user info from smart contract, for nostr private key
await useAccountStore().init();
// init store if needed
useAccountStore().init();

app.mount("#app");
// 尝试预获取 instance
try {
// 尝试预获取 instance
await useNostrStore().asyncGetNostrInstance();
} catch (e) {
// ignore
Expand Down
Loading

0 comments on commit 556d750

Please sign in to comment.