mirror of
https://github.com/KeyZox71/knl_meowscendence.git
synced 2026-01-01 06:06:41 +01:00
Merge branch 'main' into front
This commit is contained in:
@ -82,9 +82,15 @@ function getUser(user) {
|
||||
return stmt.get(user);
|
||||
}
|
||||
|
||||
function rmUser(user) {
|
||||
const stmt = database.prepare('DELETE FROM credentials WHERE username = ?');
|
||||
stmt.run(user);
|
||||
}
|
||||
|
||||
const authDB = {
|
||||
prepareDB,
|
||||
checkUser,
|
||||
rmUser,
|
||||
addUser,
|
||||
passwordQuery,
|
||||
setTOTPSecret,
|
||||
|
||||
19
src/utils/authUserRemove.js
Normal file
19
src/utils/authUserRemove.js
Normal file
@ -0,0 +1,19 @@
|
||||
import axios from 'axios'
|
||||
|
||||
/**
|
||||
* @param {string} username
|
||||
* @param {import('fastify').FastifyInstance} fastify
|
||||
*/
|
||||
export async function authUserRemove(username, fastify) {
|
||||
const url = (process.env.USER_URL || "http://localhost:3002") + "/users/" + username;
|
||||
const cookie = fastify.jwt.sign({ user: "admin" });
|
||||
|
||||
await axios.delete(
|
||||
url,
|
||||
{
|
||||
headers: {
|
||||
'Cookie': 'token=' + cookie,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -29,7 +29,7 @@ async function loadContract() {
|
||||
async function callGetScore(id) {
|
||||
try {
|
||||
const contract = await loadContract();
|
||||
const result = await contract.getScore(id);
|
||||
const result = await contract.getScore(id - 1);
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('Error calling view function:', error);
|
||||
@ -54,8 +54,9 @@ async function callAddScore(p1, p2, p1Score, p2Score) {
|
||||
const tx = await contract.addScore(p1, p2, p1Score, p2Score);
|
||||
console.log('Transaction sent:', tx.hash);
|
||||
await tx.wait(); // Wait for the transaction to be mined
|
||||
const id = await callLastId();
|
||||
console.log('Transaction confirmed');
|
||||
return tx;
|
||||
return { tx, id };
|
||||
} catch (error) {
|
||||
console.error('Error calling addScore function:', error);
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user