bruh
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
// Import required modules
|
||||
import mongoose from "mongoose";
|
||||
import UserModel from "../models/UserModel";
|
||||
import { UserModel } from "../models/UserModel";
|
||||
import * as dotenv from "dotenv";
|
||||
import { api } from '../utils/api'
|
||||
|
||||
|
@ -33,7 +33,4 @@ const userSchema = new Schema<InterfaceUsers>({
|
||||
],
|
||||
});
|
||||
|
||||
const UserModel = model<InterfaceUsers>('users', userSchema);
|
||||
|
||||
|
||||
export default UserModel;
|
||||
export const UserModel = model<InterfaceUsers>('users', userSchema);
|
||||
|
@ -11,6 +11,15 @@ const Login: React.FC = () => {
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const login = async (event: React.FormEvent) => {
|
||||
event.preventDefault();
|
||||
try {
|
||||
|
||||
} catch(error) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const returnHome = () => {
|
||||
router.push("/");
|
||||
};
|
||||
|
@ -27,6 +27,7 @@ const Signup: React.FC = () => {
|
||||
username: username,
|
||||
password: password,
|
||||
})
|
||||
|
||||
console.log(response);
|
||||
alert("Registration Complete! Now login.");
|
||||
router.push("/Login");
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
} from "~/server/api/trpc";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
|
||||
import UserModel from "~/models/UserModel";
|
||||
import { UserModel } from "~/models/UserModel";
|
||||
|
||||
// Main login router for backend
|
||||
export const loginRouter = createTRPCRouter({
|
||||
@ -30,6 +30,7 @@ export const loginRouter = createTRPCRouter({
|
||||
code: "BAD_REQUEST",
|
||||
message: "Account with email already exists!",
|
||||
})
|
||||
|
||||
}
|
||||
const saltRounds = 10;
|
||||
const hashedPassword: string = await bcrypt.hash(input.password, saltRounds);
|
||||
|
@ -12,7 +12,7 @@ import { type Session } from "next-auth";
|
||||
import superjson from "superjson";
|
||||
import { ZodError } from "zod";
|
||||
import { dbconnect } from "~/clients/mongoose";
|
||||
import UserModel from "~/models/UserModel";
|
||||
import { UserModel } from "~/models/UserModel";
|
||||
|
||||
import { getServerAuthSession } from "~/server/auth";
|
||||
|
||||
@ -40,6 +40,7 @@ interface CreateContextOptions {
|
||||
*/
|
||||
const createInnerTRPCContext = async (opts: CreateContextOptions) => {
|
||||
// Connect our database in inner context
|
||||
await dbconnect();
|
||||
return {
|
||||
session: opts.session,
|
||||
|
||||
@ -58,7 +59,7 @@ export const createTRPCContext = async ({
|
||||
}: CreateNextContextOptions) => {
|
||||
// Get the session from the server using the getServerSession wrapper function
|
||||
const session = await getServerAuthSession({ req, res });
|
||||
await dbconnect();
|
||||
|
||||
return createInnerTRPCContext({
|
||||
session,
|
||||
});
|
||||
|
Reference in New Issue
Block a user