mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-04-24 03:00:09 -04:00
fix(login): fixed token verification
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { Contract, providers, utils } from 'ethers';
|
||||
|
||||
const WELCOME_MESSAGE = `Welcome to MetaGame Anon 🐙 \n Please sign this message so we know it is you.\n We care about privacy and assure you, we don't harvest your data. Unless you create a Player account, we simply store a token in your browser's local storage. This can be removed by using the disconnect button.\n `;
|
||||
|
||||
export async function getSignature(
|
||||
provider: providers.Web3Provider,
|
||||
msg: string,
|
||||
@@ -9,7 +11,7 @@ export async function getSignature(
|
||||
const signer = provider.getSigner();
|
||||
const address = await signer.getAddress();
|
||||
if (!ethereum.request) throw new Error('No `request` On Ethereum Provider');
|
||||
const signMsg = `Welcome to MetaGame Anon 🐙 \n Please sign this message so we know it is you.\n We care about privacy and assure you, we don't harvest your data. Unless you create a Player account, we simply store a token in your browser's local storage. This can be removed by using the disconnect button.\n ${msg}`;
|
||||
const signMsg = `${WELCOME_MESSAGE}${msg}`;
|
||||
let params = [signMsg, address];
|
||||
|
||||
if (extraParams) {
|
||||
@@ -64,6 +66,9 @@ export async function verifySignature(
|
||||
): Promise<boolean> {
|
||||
const walletType = await getWalletType(address, provider);
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
message = `${WELCOME_MESSAGE}${message}`;
|
||||
|
||||
if (walletType === WalletType.EOA) {
|
||||
const recoveredAddress = utils.verifyMessage(message, signature);
|
||||
return address === recoveredAddress;
|
||||
|
||||
Reference in New Issue
Block a user