Create EIP-4361 message at signup

This commit is contained in:
silverpill 2022-02-15 01:37:19 +00:00
parent f876b509ba
commit c778025899
2 changed files with 15 additions and 4 deletions

View file

@ -39,7 +39,8 @@ export interface User extends Profile {
export interface UserCreateForm {
username: string;
password: string;
wallet_address: string;
message: string;
signature: string;
invite_code: string | null;
}

View file

@ -55,7 +55,6 @@ import { Options, Vue, setup } from "vue-class-component"
import {
createUser,
getAccessToken,
getAccessTokenEip4361,
getCurrentUser,
} from "@/api/users"
@ -98,6 +97,7 @@ export default class LandingPage extends Vue {
if (!provider || !this.store.instance) {
return
}
const instanceHost = this.store.instance.uri
const loginMessage = this.store.instance.login_message
const walletAddress = await getWalletAddress(provider)
if (!walletAddress) {
@ -107,6 +107,15 @@ export default class LandingPage extends Vue {
if (!signature) {
return
}
const signer = await getWallet()
if (!signer) {
return
}
const { message, signature: eip4361signature } = await createEip4361_SignedMessage(
signer,
instanceHost,
loginMessage,
)
this.isLoading = true
let user
let authToken
@ -114,10 +123,11 @@ export default class LandingPage extends Vue {
user = await createUser({
username: this.username,
password: signature,
wallet_address: walletAddress,
message,
signature: eip4361signature,
invite_code: this.inviteCode,
})
authToken = await getAccessToken({ wallet_address: walletAddress, signature })
authToken = await getAccessTokenEip4361(message, eip4361signature)
} catch (error) {
this.isLoading = false
this.registrationErrorMessage = error.message