diff --git a/controller/User.controller.js b/controller/User.controller.js index 0e347a4..ab50453 100644 --- a/controller/User.controller.js +++ b/controller/User.controller.js @@ -29,8 +29,20 @@ exports.User_Findone=( req, res ) => { - User.find(req.body).then( user => res.json(' user found' + user)).catch( err => res.status(400).json('Error : ' + err)); + User.findOne(req.body).then( user => res.json(' user found' + user)).catch( err => res.status(400).json('Error : ' + err)); + + + +} +/* +exports.User_FindStudents=( req, res ) => +{ + + + User.find(req.body).then( user => res.json(' user found' + user)).catch( err => res.status(400).json('Error : ' + err)); + + -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/models/User.model.js b/models/User.model.js index 16aa5bb..6a7bb30 100644 --- a/models/User.model.js +++ b/models/User.model.js @@ -11,8 +11,8 @@ const mongoose = require('mongoose'); const User_Schema = new Schema({ name : {type : String, required : true , index:{unique : true }}, - password: { type : String, required : true} - + password: { type : String, required : true}, + role : {type : String , required : true} }) diff --git a/nodetest.js b/nodetest.js index 71ceafa..8d20dbd 100644 --- a/nodetest.js +++ b/nodetest.js @@ -2,6 +2,12 @@ var massege = ' hello world'; console.log(massege); const cors = require('cors'); +const corsOptions ={ + + origin : '*', + credentials :true, + optionSuccessStatus:200, +} const { MongoClient, HostAddress } = require("mongodb"); const { default: test } = require("node:test"); @@ -18,6 +24,7 @@ const client = new MongoClient(uri); const app = express(); //app.use(bodyparser.json()); app.use(express.json()); +app.use(cors(corsOptions)); app.use(express.urlencoded({ extended: false })); const port = 5000; @@ -35,7 +42,7 @@ app.use('/module', moduleRouter); app.use ('/tutorial', tutorialrouter); app.use ('/user', userrouter); -app.use(cors()); + /////