moved username set from launcher to web
This commit is contained in:
parent
5e0c4f0e90
commit
c682d7727e
|
|
@ -1,5 +1,5 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
import { useRouter } from 'next/router';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { usePrivy } from '@privy-io/react-auth';
|
import { usePrivy } from '@privy-io/react-auth';
|
||||||
|
|
@ -7,7 +7,7 @@ import Link from 'next/link';
|
||||||
|
|
||||||
const Home: React.FC = () => {
|
const Home: React.FC = () => {
|
||||||
const { login, ready, user } = usePrivy();
|
const { login, ready, user } = usePrivy();
|
||||||
|
const router = useRouter(); //
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
const setResult = async (result: string, wallet: string) => {
|
const setResult = async (result: string, wallet: string) => {
|
||||||
|
|
@ -18,6 +18,17 @@ const Home: React.FC = () => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
//Get username from database
|
||||||
|
const response = await fetch(`https://vps.playpoolstudios.com/metahunt/api/launcher/get_display_name_public.php?id=${user?.id}`);
|
||||||
|
const databaseUsername = await response.text();
|
||||||
|
|
||||||
|
if (databaseUsername == "-1") {
|
||||||
|
console.log(user?.id);
|
||||||
|
router.push("/logincomplete?request_id=" + requestIdFromUrl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await axios({
|
await axios({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: `https://vps.playpoolstudios.com/metahunt/api/launcher/set_request_response.php`,
|
url: `https://vps.playpoolstudios.com/metahunt/api/launcher/set_request_response.php`,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { usePrivy } from "@privy-io/react-auth";
|
import { usePrivy } from "@privy-io/react-auth";
|
||||||
|
import axios from "axios";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { SetStateAction, useEffect, useState } from "react";
|
import { SetStateAction, useEffect, useState } from "react";
|
||||||
|
|
@ -19,6 +20,49 @@ export default function LoginComplete() {
|
||||||
}
|
}
|
||||||
},[ready, user])
|
},[ready, user])
|
||||||
|
|
||||||
|
const setResult = async (result: string, wallet: string) => {
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const requestIdFromUrl = params.get('request_id');
|
||||||
|
|
||||||
|
if (!result.includes('privy')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
|
||||||
|
//Get username from database
|
||||||
|
const response = await fetch(`https://vps.playpoolstudios.com/metahunt/api/launcher/get_display_name_public.php?id=${user?.id}`);
|
||||||
|
const databaseUsername = await response.text();
|
||||||
|
|
||||||
|
if (databaseUsername == "-1") {
|
||||||
|
console.log(user?.id);
|
||||||
|
router.push("/logincomplete?request_id=" + requestIdFromUrl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await axios({
|
||||||
|
method: 'get',
|
||||||
|
url: `https://vps.playpoolstudios.com/metahunt/api/launcher/set_request_response.php`,
|
||||||
|
withCredentials: false,
|
||||||
|
params: {
|
||||||
|
id: requestIdFromUrl,
|
||||||
|
result: result
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log(`https://vps.playpoolstudios.com/metahunt/api/launcher/set_request_response.php?id=${requestIdFromUrl}&result=${result}`);
|
||||||
|
await axios({
|
||||||
|
method: 'get',
|
||||||
|
url: `https://vps.playpoolstudios.com/metahunt/api/launcher/set_wallet.php`,
|
||||||
|
withCredentials: false,
|
||||||
|
params: {
|
||||||
|
id: result,
|
||||||
|
wallet: wallet,
|
||||||
|
init: "true"
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error making GET request:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
const handleClaim = async () => {
|
const handleClaim = async () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -33,6 +77,8 @@ export default function LoginComplete() {
|
||||||
url
|
url
|
||||||
);
|
);
|
||||||
// Optionally, handle successful username set
|
// Optionally, handle successful username set
|
||||||
|
setResult(user?.id ?? "", user?.wallet?.address ?? "");
|
||||||
|
|
||||||
console.log("Username successfully set!");
|
console.log("Username successfully set!");
|
||||||
router.push("/dashboard");
|
router.push("/dashboard");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user