wasowasowaso
This commit is contained in:
@@ -1,26 +1,34 @@
|
||||
import mysql2, { Connection, RowDataPacket, OkPacket, QueryError } from "mysql2";
|
||||
import { getConnection } from "@/db";
|
||||
// import { getConnection } from "@/db";
|
||||
import { Post, postPlaceholder } from "@/model/Models";
|
||||
import { getPosts, IPost } from "@/controller/Post";
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
// import { MPost, MUser, MAuth } from "@/model/Models"
|
||||
import { MPost } from "@/model/sequelize/Post";
|
||||
// import { MPost } from "@/model/sequelize/Post";
|
||||
// import { MAuth } from "@/model/sequelize/Auth";
|
||||
import { MUser } from "@/model/sequelize/User";
|
||||
import { MAuth } from "@/model/sequelize/Auth";
|
||||
|
||||
|
||||
import { DataType, Model, Sequelize, UUID } from "sequelize";
|
||||
import { validatePassword, hashPassword } from "@/util/Auth";
|
||||
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
if (req.method === 'POST') {
|
||||
async function POST(req: NextApiRequest, res: NextApiResponse){
|
||||
MUser.sync();
|
||||
const username = req.body.username;
|
||||
const password = req.body.password;
|
||||
console.log(req.body);
|
||||
const user = await MUser.sync()
|
||||
const userTable = await MUser.sync()
|
||||
let user = await MUser.findOne({ where: { username: username } });
|
||||
const hash = await hashPassword(password)
|
||||
if (user == undefined) {
|
||||
const hash = await hashPassword(password)
|
||||
user = await MUser.create({
|
||||
username: username,
|
||||
password: hash
|
||||
})
|
||||
}
|
||||
.then(async f => {
|
||||
return await MUser.findOne({ where: { username: username } });
|
||||
return
|
||||
})
|
||||
.then(async user => {
|
||||
if (user == undefined) {
|
||||
@@ -40,5 +48,15 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
.catch(error => {
|
||||
res.status(500).json(error);
|
||||
});
|
||||
}
|
||||
async function GET(req: NextApiRequest, res: NextApiResponse){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
if (req.method === 'POST') {
|
||||
POST();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user