최동원

api fix

......@@ -50,10 +50,10 @@ app.use(express.static('views'));
app.use(passport.initialize());
app.use(passport.session());
app.use('/', indexRouter);
app.use('/user', userRouter);
app.use('/login', loginRouter);
app.use('/RegistUser', registerRouter);
app.use('/api/', indexRouter);
app.use('/api/user', userRouter);
app.use('/api/login', loginRouter);
app.use('/api/RegistUser', registerRouter);
//app.use('/users', usersRouter);
// catch 404 and forward to error handler
......
......@@ -20,7 +20,7 @@ router.post('/', function(req, res, next) {
if(bytes===user_pw) {
console.log("user login successfully");
req.session.user_id=result[0].user_id;
res.redirect('/main');
res.status(200).send({ user_id: result[0].user_id });
}else{
console.log("wrong password!");
}
......
......@@ -21,7 +21,7 @@ router.post('/', function(req, res, next) {
var user_phone=req.body.user_phone;
var sqlquery = "SELECT * FROM users WHERE user_id = ?";
connection.query(sqlquery, [user_id], function (err, result) {
connection.query(sqlquery, [user_id], function (err, rows) {
if (rows.length == 0) {
user_pw=cryptoM.encrypt(user_pw);
console.log(user_pw);
......@@ -32,13 +32,12 @@ router.post('/', function(req, res, next) {
console.log("inserting user failed");
throw err;
} else {
res.redirect('/login');
res.status(200).send('saved');
}
});
} else {
res.redirect("/login");
throw err;
res.status(404).send(err);
}
});
});
......