Role nd token Based Routing completed for Project,trash,home which is in Controller. Token, Auth Purpose,Rolebased middlewares created. Auth API,Project token Based API, Home Token Based API, Trash Token Based API In v1 AuthRoutes

This commit is contained in:
2025-05-19 16:06:09 +05:30
parent 2aa8c479fa
commit ac8de5d33d
28 changed files with 1748 additions and 224 deletions

View File

@@ -3,14 +3,14 @@ import MainModel from "../../connect/mongoose.ts";
import { User } from "./userAuthModel.ts";
export interface Token extends Document {
userId: User["_id"];
isArchieve: Boolean;
isArchive: Boolean;
refreshToken: string;
resetTokenExpiry?: Date;
resetToken: string;
}
const tokenSchema: Schema = new Schema({
userId: { type: Schema.Types.ObjectId, ref: "User" },
isArchieve: { type: Boolean, default: false },
isArchive: { type: Boolean, default: false },
token: { type: String },
refreshToken: { type: String },
tokenCreatedAt: { type: Date },

View File

@@ -3,41 +3,44 @@ import MainModel from "../../connect/mongoose.ts";
import { User } from "./userAuthModel.ts";
export interface UserData extends Document {
userId: User["_id"];
isShare: Boolean;
activeStatus: string;
notificationEnable: boolean;
About: string;
isArchieve: boolean;
Role: string;
Profilepicture: string;
isArchive: boolean;
role: string;
profilePicture: string;
recentlyViewed: string[];
CheckIn: number;
CheckOut: number;
}
const UserDataSchema: Schema = new Schema({
userId: { type: Schema.Types.ObjectId, ref: "User" },
isArchieve: { type: Boolean, default: false },
isArchive: { type: Boolean, default: false },
notificationEnable: { type: Boolean, default: false },
About: {
type: String,
},
Role: {
role: {
type: String,
default: "User",
enum: ["User", "Admin"],
},
isShare: {
type: Boolean,
default: false,
},
activeStatus: {
type: String,
enum: ["online", "offline"],
default: "offline",
},
recentlyViewed: {
type: [String],
default: [],
},
Profilepicture: {
profilePicture: {
type: String,
// default: "default-profile-picture.jpg"
},
CheckIn: {
type: Number,
},
CheckOut: {
type: Number,
},
});
const UsersDataModel = (db: any) => {

View File

@@ -1,15 +1,15 @@
import { Schema, Document } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
export interface User extends Document {
Username: string;
userName: string;
Email: string;
Password: string;
isArchieve: boolean;
isArchive: boolean;
visitorBrowserID: string;
lastPasswordReset: number;
}
const signupschema: Schema = new Schema({
Username: {
const AuthSchema: Schema = new Schema({
userName: {
type: String,
required: true,
},
@@ -23,12 +23,12 @@ const signupschema: Schema = new Schema({
min: 8,
// required: true,
},
isArchieve: { type: Boolean, default: false },
isArchive: { type: Boolean, default: false },
lastPasswordReset: { type: Number },
visitorBrowserID: { type: String },
});
const userModel = (db: any) => {
return MainModel(db, "User", signupschema, "User");
const AuthModel = (db: any) => {
return MainModel(db, "UserAuth", AuthSchema, "UserAuth");
};
export default userModel;
export default AuthModel;

View File

@@ -0,0 +1,52 @@
import mongoose, { Document, Schema } from "mongoose";
import MainModel from "../../connect/mongoose.ts";
export interface IShare extends Document {
Createdby: {
userId: mongoose.Types.ObjectId;
Email: string;
};
isActive: boolean;
Share_People: [
{
userId: mongoose.Types.ObjectId;
Email: string;
AccessPoint: string;
}
];
Description: string;
createdAt: number;
projectId: mongoose.Types.ObjectId;
}
const shareSchema: Schema = new Schema({
CreatedBy: {
userId: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
required: true,
},
Email: { type: String, ref: "User", required: true },
},
isActive: { type: Boolean, default: false },
Share_People: [
{
userId: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
Email: { type: String, ref: "User", required: true },
AccessPoint: {
type: String,
default: "Can view",
enum: ["Can view", "Can edit", "Can comment"],
},
},
],
createdAt: {
type: Number,
default: Date.now(),
},
projectId: { type: mongoose.Schema.Types.ObjectId, ref: "Scene" },
});
const shareModel = (db: any) => {
return MainModel(db, "Shared", shareSchema, "Shared");
};
export default shareModel;