Create EIP-4361 message at signup
This commit is contained in:
parent
f876b509ba
commit
c778025899
2 changed files with 15 additions and 4 deletions
|
@ -39,7 +39,8 @@ export interface User extends Profile {
|
||||||
export interface UserCreateForm {
|
export interface UserCreateForm {
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
wallet_address: string;
|
message: string;
|
||||||
|
signature: string;
|
||||||
invite_code: string | null;
|
invite_code: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,6 @@ import { Options, Vue, setup } from "vue-class-component"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createUser,
|
createUser,
|
||||||
getAccessToken,
|
|
||||||
getAccessTokenEip4361,
|
getAccessTokenEip4361,
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
} from "@/api/users"
|
} from "@/api/users"
|
||||||
|
@ -98,6 +97,7 @@ export default class LandingPage extends Vue {
|
||||||
if (!provider || !this.store.instance) {
|
if (!provider || !this.store.instance) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const instanceHost = this.store.instance.uri
|
||||||
const loginMessage = this.store.instance.login_message
|
const loginMessage = this.store.instance.login_message
|
||||||
const walletAddress = await getWalletAddress(provider)
|
const walletAddress = await getWalletAddress(provider)
|
||||||
if (!walletAddress) {
|
if (!walletAddress) {
|
||||||
|
@ -107,6 +107,15 @@ export default class LandingPage extends Vue {
|
||||||
if (!signature) {
|
if (!signature) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const signer = await getWallet()
|
||||||
|
if (!signer) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const { message, signature: eip4361signature } = await createEip4361_SignedMessage(
|
||||||
|
signer,
|
||||||
|
instanceHost,
|
||||||
|
loginMessage,
|
||||||
|
)
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
let user
|
let user
|
||||||
let authToken
|
let authToken
|
||||||
|
@ -114,10 +123,11 @@ export default class LandingPage extends Vue {
|
||||||
user = await createUser({
|
user = await createUser({
|
||||||
username: this.username,
|
username: this.username,
|
||||||
password: signature,
|
password: signature,
|
||||||
wallet_address: walletAddress,
|
message,
|
||||||
|
signature: eip4361signature,
|
||||||
invite_code: this.inviteCode,
|
invite_code: this.inviteCode,
|
||||||
})
|
})
|
||||||
authToken = await getAccessToken({ wallet_address: walletAddress, signature })
|
authToken = await getAccessTokenEip4361(message, eip4361signature)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
this.registrationErrorMessage = error.message
|
this.registrationErrorMessage = error.message
|
||||||
|
|
Loading…
Reference in a new issue