박유빈

edit README, change the front code flutter to ejs

......@@ -5,6 +5,28 @@
"version": "0.2.0",
"configurations": [
{
"name": "Launch via NPM",
"request": "launch",
"runtimeArgs": [
"run-script",
"debug"
],
"runtimeExecutable": "npm run start:dev",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
{
"program": "${workspaceFolder}/app.js",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
......
......@@ -19,7 +19,7 @@ server use Node.js, Koa.js and frotend use flutter(Dart)
* [Node.js](https://nodejs.org/)
* [Koa.js](https://koajs.com/)
* [flutter](https://flutter.dev/)
......@@ -31,7 +31,6 @@ server use Node.js, Koa.js and frotend use flutter(Dart)
## Getting Started
Go to the Server [Project folder](http://khuhub.khu.ac.kr/2018102946/likeBack), and git clone.
And go the Frontend [Project folder](http://khuhub.khu.ac.kr/2018102946/likefront)and git clone.
### Installation
......@@ -72,7 +71,7 @@ _Below is an example of how you can instruct your audience on installing and set
Your Name -- email@example.com
Project Link: [http://khuhub.khu.ac.kr/2018102946/likeBack](http://khuhub.khu.ac.kr/2018102946/likeBack)
[http://khuhub.khu.ac.kr/2018102946/likefront](http://khuhub.khu.ac.kr/2018102946/likefront)
<p align="right">(<a href="#top">back to top</a>)</p>
......
[debug] [2021-12-06T16:19:50.991Z] ----------------------------------------------------------------------
[debug] [2021-12-06T16:19:50.996Z] Command: /usr/local/bin/node /usr/local/bin/firebase login
[debug] [2021-12-06T16:19:50.997Z] CLI Version: 9.23.0
[debug] [2021-12-06T16:19:50.997Z] Platform: linux
[debug] [2021-12-06T16:19:50.998Z] Node Version: v16.13.0
[debug] [2021-12-06T16:19:51.007Z] Time: Tue Dec 07 2021 01:19:50 GMT+0900 (Korean Standard Time)
[debug] [2021-12-06T16:19:51.008Z] ----------------------------------------------------------------------
[debug]
[debug] [2021-12-06T16:19:51.014Z] >>> [apiv2][query] GET https://firebase-public.firebaseio.com/cli.json [none]
[info] i Firebase optionally collects CLI usage and error reporting information to help improve our products. Data is collected in accordance with Google's privacy policy (https://policies.google.com/privacy) and is not used to identify you.
[debug] [2021-12-06T16:19:52.476Z] <<< [apiv2][status] GET https://firebase-public.firebaseio.com/cli.json 200
[debug] [2021-12-06T16:19:52.476Z] <<< [apiv2][body] GET https://firebase-public.firebaseio.com/cli.json {"cloudBuildErrorAfter":1594252800000,"cloudBuildWarnAfter":1590019200000,"defaultNode10After":1594252800000,"minVersion":"3.0.5","node8DeploysDisabledAfter":1613390400000,"node8RuntimeDisabledAfter":1615809600000,"node8WarnAfter":1600128000000}
[info] i To change your data collection preference at any time, run `firebase logout` and log in again.
[info]
[info] Visit this URL on this device to log in:
[info] https://accounts.google.com/o/oauth2/auth?client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&scope=email%20openid%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloudplatformprojects.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ffirebase%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&response_type=code&state=406504610&redirect_uri=http%3A%2F%2Flocalhost%3A9005
[info]
[info] Waiting for authentication...
......@@ -21,12 +21,15 @@
"koa": "^2.13.4",
"koa-body": "^4.2.0",
"koa-bodyparser": "^4.3.0",
"koa-ejs": "^4.3.0",
"koa-passport": "^4.1.4",
"koa-router": "^10.1.1",
"koa-send": "^5.0.1",
"mongoose": "^6.0.12",
"nodemailer": "^6.7.1",
"passport": "^0.5.0",
"passport-google-oauth": "^2.0.0",
"passport-local": "^1.0.0",
"spdy": "^4.0.2"
},
"devDependencies": {
......@@ -1109,6 +1112,11 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/any-promise": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
"integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8="
},
"node_modules/aproba": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz",
......@@ -1553,6 +1561,15 @@
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"node_modules/ejs": {
"version": "2.7.4",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-2.7.4.tgz",
"integrity": "sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==",
"hasInstallScript": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
......@@ -2620,6 +2637,39 @@
"node": ">= 10"
}
},
"node_modules/koa-ejs": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/koa-ejs/-/koa-ejs-4.3.0.tgz",
"integrity": "sha512-KK1B1YEeq8TOt7hrHwohfHxH03ZqsdhQWeFjmvcWk3arVI/uQOyE4FHQVlg0Ud9eXxlgUfkYqA2MJhfK4ADkAw==",
"dependencies": {
"debug": "^2.6.1",
"ejs": "^2.6.1",
"mz": "^2.6.0"
}
},
"node_modules/koa-passport": {
"version": "4.1.4",
"resolved": "https://registry.npmjs.org/koa-passport/-/koa-passport-4.1.4.tgz",
"integrity": "sha512-dJBCkl4X+zdYxbI2V2OtoGy0PUenpvp2ZLLWObc8UJhsId0iQpTFT8RVcuA0709AL2txGwRHnSPoT1bYNGa6Kg==",
"dependencies": {
"passport": "^0.4.0"
},
"engines": {
"node": ">= 4"
}
},
"node_modules/koa-passport/node_modules/passport": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/passport/-/passport-0.4.1.tgz",
"integrity": "sha512-IxXgZZs8d7uFSt3eqNjM9NQ3g3uQCW5avD8mRNoXV99Yig50vjuaez6dQK2qC0kVWPRTujxY0dWgGfT09adjYg==",
"dependencies": {
"passport-strategy": "1.x.x",
"pause": "0.0.1"
},
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/koa-router": {
"version": "10.1.1",
"resolved": "https://registry.npmjs.org/koa-router/-/koa-router-10.1.1.tgz",
......@@ -3102,6 +3152,16 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"node_modules/mz": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz",
"integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==",
"dependencies": {
"any-promise": "^1.0.0",
"object-assign": "^4.0.1",
"thenify-all": "^1.0.0"
}
},
"node_modules/natural-compare": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
......@@ -3192,6 +3252,14 @@
"resolved": "https://registry.npmjs.org/oauth/-/oauth-0.9.15.tgz",
"integrity": "sha1-vR/vr2hslrdUda7VGWQS/2DPucE="
},
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/obuf": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz",
......@@ -3310,6 +3378,17 @@
"node": ">= 0.4.0"
}
},
"node_modules/passport-local": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/passport-local/-/passport-local-1.0.0.tgz",
"integrity": "sha1-H+YyaMkudWBmJkN+O5BmYsFbpu4=",
"dependencies": {
"passport-strategy": "1.x.x"
},
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/passport-oauth1": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/passport-oauth1/-/passport-oauth1-1.2.0.tgz",
......@@ -3911,6 +3990,25 @@
"integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=",
"dev": true
},
"node_modules/thenify": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz",
"integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==",
"dependencies": {
"any-promise": "^1.0.0"
}
},
"node_modules/thenify-all": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz",
"integrity": "sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY=",
"dependencies": {
"thenify": ">= 3.1.0 < 4"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/tmp": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz",
......@@ -5125,6 +5223,11 @@
"color-convert": "^2.0.1"
}
},
"any-promise": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
"integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8="
},
"aproba": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz",
......@@ -5457,6 +5560,11 @@
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"ejs": {
"version": "2.7.4",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-2.7.4.tgz",
"integrity": "sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA=="
},
"emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
......@@ -6329,6 +6437,35 @@
"koa-compose": "^4.1.0"
}
},
"koa-ejs": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/koa-ejs/-/koa-ejs-4.3.0.tgz",
"integrity": "sha512-KK1B1YEeq8TOt7hrHwohfHxH03ZqsdhQWeFjmvcWk3arVI/uQOyE4FHQVlg0Ud9eXxlgUfkYqA2MJhfK4ADkAw==",
"requires": {
"debug": "^2.6.1",
"ejs": "^2.6.1",
"mz": "^2.6.0"
}
},
"koa-passport": {
"version": "4.1.4",
"resolved": "https://registry.npmjs.org/koa-passport/-/koa-passport-4.1.4.tgz",
"integrity": "sha512-dJBCkl4X+zdYxbI2V2OtoGy0PUenpvp2ZLLWObc8UJhsId0iQpTFT8RVcuA0709AL2txGwRHnSPoT1bYNGa6Kg==",
"requires": {
"passport": "^0.4.0"
},
"dependencies": {
"passport": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/passport/-/passport-0.4.1.tgz",
"integrity": "sha512-IxXgZZs8d7uFSt3eqNjM9NQ3g3uQCW5avD8mRNoXV99Yig50vjuaez6dQK2qC0kVWPRTujxY0dWgGfT09adjYg==",
"requires": {
"passport-strategy": "1.x.x",
"pause": "0.0.1"
}
}
}
},
"koa-router": {
"version": "10.1.1",
"resolved": "https://registry.npmjs.org/koa-router/-/koa-router-10.1.1.tgz",
......@@ -6684,6 +6821,16 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"mz": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz",
"integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==",
"requires": {
"any-promise": "^1.0.0",
"object-assign": "^4.0.1",
"thenify-all": "^1.0.0"
}
},
"natural-compare": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
......@@ -6758,6 +6905,11 @@
"resolved": "https://registry.npmjs.org/oauth/-/oauth-0.9.15.tgz",
"integrity": "sha1-vR/vr2hslrdUda7VGWQS/2DPucE="
},
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
},
"obuf": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz",
......@@ -6851,6 +7003,14 @@
"passport-oauth2": "1.x.x"
}
},
"passport-local": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/passport-local/-/passport-local-1.0.0.tgz",
"integrity": "sha1-H+YyaMkudWBmJkN+O5BmYsFbpu4=",
"requires": {
"passport-strategy": "1.x.x"
}
},
"passport-oauth1": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/passport-oauth1/-/passport-oauth1-1.2.0.tgz",
......@@ -7305,6 +7465,22 @@
"integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=",
"dev": true
},
"thenify": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz",
"integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==",
"requires": {
"any-promise": "^1.0.0"
}
},
"thenify-all": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz",
"integrity": "sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY=",
"requires": {
"thenify": ">= 3.1.0 < 4"
}
},
"tmp": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz",
......
......@@ -6,7 +6,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node src",
"start:dev": "nodemon --watch src/ src/index.js"
"start:dev": "NODE_PATH=src nodemon --legacy-watch src/ src/index.js"
},
"author": "",
"license": "ISC",
......@@ -23,12 +23,15 @@
"koa": "^2.13.4",
"koa-body": "^4.2.0",
"koa-bodyparser": "^4.3.0",
"koa-ejs": "^4.3.0",
"koa-passport": "^4.1.4",
"koa-router": "^10.1.1",
"koa-send": "^5.0.1",
"mongoose": "^6.0.12",
"nodemailer": "^6.7.1",
"passport": "^0.5.0",
"passport-google-oauth": "^2.0.0",
"passport-local": "^1.0.0",
"spdy": "^4.0.2"
},
"devDependencies": {
......
......@@ -6,6 +6,9 @@ const nodemailer = require('nodemailer');
const config = require('../../lib/config');
const { Mongoose } = require('mongoose');
const { exist, allow } = require('@hapi/joi');
const index = require('../../../src/index');
const render = index.render;
const fs = require('fs');
exports.test = async (ctx) => {
console.log('cookie');
......@@ -61,7 +64,7 @@ exports.signupLocal = async (ctx) => {
// 응답할 데이터에서 hashedPassword 필드 제거
ctx.status = 200;
ctx.body = await account.serialize();
await ctx.render('users/new');
} catch (e) {
ctx.throw(500, e);
}
......@@ -97,6 +100,7 @@ exports.signinLocal = async (ctx) => {
httpOnly: false,
});
ctx.status = 200;
await ctx.render('users/index');
console.log('토큰나옴');
} catch (e) {
ctx.throw(500, e);
......
......@@ -3,6 +3,7 @@ const Router = require("@koa/router");
const authCtrl = require("./auth.ctrl");
const checkLoggedIn = require("../../lib/checkLoggedIn");
var passport = require('passport');
const User = require("../../models/user");
var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
const auth = new Router();
......@@ -26,12 +27,72 @@ auth.get('/book',checkLoggedIn,authCtrl.getUserBook);
auth.get('/user', checkLoggedIn,authCtrl.userinfo); // show user information
auth.patch('/user', checkLoggedIn, authCtrl.updateUser); // modify user information
auth.patch('/user/password', authCtrl.changePassword); // change password
auth.post('/find/password', authCtrl.findPassword); // 비밀번호 찾기
auth.get('/favorite',checkLoggedIn, authCtrl.showFavorite); // show a list of user's favorites
auth.post('/favorite',checkLoggedIn, authCtrl.addFavorite); // add favorite
auth.delete('/favorite',checkLoggedIn, authCtrl.delFavorite); // delete favorite
auth.post('/find/password', authCtrl.findPassword); // 비밀번호 찾기
auth.get('/new', async (ctx) => {
ctx.render('users/new');
});
auth.get('/', async (ctx) => {
try{
const user = await User.find({}).sort({email:-1}).exec();//1 오름차순 -1내림차순
ctx.render('users/index', {users});
}catch(e){
ctx.throw(500, e);
}
}
);
// show
auth.get('/:username', async (ctx) => {
const user = await User.findOne({_id:ctx.params._id});
ctx.render('users/show', {user});
});
// edit
auth.get('/:username/edit', async (ctx) => {
const user = await User.findOne({username:ctx.params.username});
ctx.render('users/edit', {user:user});
});
// update // 2
auth.post('/:username', async (ctx) => {
await User.findOne({username:ctx.params.username}).select('password').exec();
// update user object
user.originalPassword = user.password;
user.password = ctx.body.newPassword? ctx.body.newPassword : user.password; // 2-3
for(var p in ctx.body) // 2-4
user[p] = ctx.body[p];
// save updated user
await user.save();
ctx.redirect('/users/'+user.nickname);
});
// destroy
auth.delete('/:username',async (ctx) => {
try{
var username = ctx.params.username;
await User.deleteOne({username:username});
ctx.redirect('/users');
}catch(e){
ctx.throw(500, e);
}
});
module.exports = auth;
\ No newline at end of file
......
......@@ -9,13 +9,13 @@ exports.booklist = async (ctx) => {
try {
book = await Book.find()
.sort({created: -1})
.sort({createDate: -1})
.exec();
await ctx.render('books/index', {book:book});
} catch (e) {
return ctx.throw(500, e);
}
ctx.body = book;
console.log('get /book/booklist');
}
}
......@@ -55,12 +55,12 @@ exports.addBook = async (ctx) => {
if (err) throw err;
const user = await User.findById(ctx.state.user._id).exec();
console.log(book._id);
ctx.redirect('/books');
});
} catch (e) {
ctx.throw(500, e);
}
ctx.body = book;
console.log('저장 성공!');
ctx.status = 200;
};
......@@ -97,44 +97,67 @@ exports.updateBook = async (ctx) => {
ctx.request.body.cover = fs.readFileSync(file.image.path);
else
ctx.request.body.cover = ""
var book = ctx.request.body; //require books's _id
try {
const mybook = await Book.findOne({ _id: book._id });
mybook.updateB(book);
ctx.body = book._id;
} catch (e) {
ctx.throw(500, e);
}
ctx.body = book._id;
console.log(book);
ctx.status = 200;
const mybook = await Book.findOne({ _id: book._id });
if(ctx.state.user._id == mybook.author){
mybook.updateB(book);
ctx.body = book._id;
ctx.status = 200;}
}
catch (e) {
ctx.throw(500, e);
ctx.status = 400;
ctx.body = {
message: "작성자가 아닙니다. " }
}
};
exports.deleteBook = async (ctx) => {
let bookid = ctx.query.id;
try {
var b = await Book.find(ctx.params.id);
await Page.deleteMany({"pages":{$in:b.pages}});//book에 있던 페이지 다 지우기
//var foundB = await Book.findById(bookid).exec();
//북작가에게서 책 정보 지우기
var author = await User.findById(bookid);//북 작가.
console.log(author);
console.log(author.books);
await User.delBook(ctx.state.user.email,bookid);
//book에 있던 페이지 다 지우기
await Page.deleteMany({"pages":{$in:b.pages}});
//최종 book지우기
var b = await Book.deleteOne({_id:bookid});
} catch (e) {
if(e.name === 'CastError') {
ctx.status = 400;
return;
}
}
ctx.status = 204; // No Content
console.log('delete success');
ctx.body = {
message: "Delete"
}
};
exports.detailBook = async (ctx) => {
var ObjectId = require('mongodb').ObjectId;
var id = req.params.book_id;
var o_id = new ObjectId(id);
const book = await db.Book.find({_id:o_id});
ctx.body = book;
try{
var id = ctx.params.id;
const book = await dBook.find({_id:id});
ctx.render('books/show', {book:book});
ctx.status = 200;
} catch (e) {
ctx.status = 400;
console.log('북 삭제 오류');
}
};
exports.scrollBook = async (ctx) => {
......@@ -154,8 +177,4 @@ exports.scrollBook = async (ctx) => {
ctx.throw(500, e);
}
}
else if(filter === "추천순") { //추천순
}
};
......
......@@ -11,5 +11,7 @@ book.patch('/', checkLoggedIn, bookCtrl.updateBook); // modify book information
book.delete('/',checkLoggedIn,bookCtrl.deleteBook); // delete book
book.get('/booklist',bookCtrl.booklist);
book.get('/search',bookCtrl.scrollBook);
book.get('/new', async (ctx) => {
ctx.render('books/new');
});
module.exports = book;
\ No newline at end of file
......
......@@ -2,8 +2,11 @@ const Router = require("@koa/router");
const checkLoggedIn = require("../../lib/checkLoggedIn");
const pageCtrl = require("./page.ctrl");
const page = new Router();
const Page = require("../../models/page");
const index = require('../../../src/index');
//Page api
/*
page.get('/',pageCtrl.getPage); // show a list of user's pages
page.post('/',checkLoggedIn,pageCtrl.addPage); // add page
page.patch('/', checkLoggedIn,pageCtrl.updatePage); // modify page information
......@@ -11,13 +14,61 @@ page.delete('/',checkLoggedIn,pageCtrl.deletePage); // delete book
page.get('/search', pageCtrl.search); // /search?title=search_query&petType=petType
//page.post('/search/filter', pageCtrl.searchFilter); //아직 구현 안함
page.post('/detail', pageCtrl.detailPage); // detail recipe page
page.post('/:id', pageCtrl.detailPage); // detail recipe page
//page.get('/recipe/slide', pageCtrl.slidRecipe); // 5 recommended videos in main page
// /recipe/scroll?filter=filter_query&renewal=count (filter_query: 추천순 or 조회순)
page.get('/recipe/scroll', pageCtrl.scrollPage); // video list sorted by 추천순 or 조회순 in main page
*/
page.get('/', async (ctx) => {
const page = await Page.find({}).sort({createDate:-1}).exec();
console.log(page);
await ctx.render('posts/index', {page});
});
page.get('/new', async (ctx) => {
ctx.render('posts/new');
});
// create
page.post('/', async (ctx, next) => {
await Page.create(ctx.body);
ctx.redirect('/posts');
});
// show
page.get('/:id', async (ctx, next) => {
const page = await Page.findOne({_id:ctx.params.id});
ctx.render('posts/show', {page});
});
// update
page.post('/:id', async (ctx, next) => {
ctx.body.updatedAt = Date.now(); //2
const page = await Page.findOneAndUpdate({_id:ctx.params.id}, ctx.body);
ctx.redirect("/posts/"+ctx.params.id);
});
// destroy
page.delete('/:id', async (ctx, next) => {
try{
await Page.deleteOne({_id:ctx.params.id})
ctx.redirect('/posts');
}catch(e){
ctx.throw(500, e);
}
});
//page.post('/postinfo', pageCtrl.uploadInfo);
//page.get('/info',pageCtrl.getbyurl);//url로 recipe정보 가져오기 (flutter 내 레시피에서 쓰임.)
module.exports = page;
\ No newline at end of file
module.exports = page;
......
......@@ -4,6 +4,8 @@ const Book = require("../../models/book");
const Joi = require('@hapi/joi');
const config = require('../../lib/config');
const { Mongoose } = require('mongoose');
exports.search = async (ctx) => {
const { title } = ctx.query; //search word
console.log(title)
......@@ -19,12 +21,18 @@ exports.search = async (ctx) => {
exports.detailPage = async (ctx) => {
var ObjectId = require('mongodb').ObjectId;
var id = req.params.page_id;
try{
var ObjectId = require('mongodb').ObjectId;
var id = req.params.id;
var o_id = new ObjectId(id);
const page = await db.Page.find({_id:o_id});
await ctx.redirect('/api/page/detail/'+req.params.id);
ctx.body = page;
ctx.status = 200;
}catch(e){
ctx.throw(500,e);
}
};
// parameters: array with book objects as elements
......@@ -149,19 +157,21 @@ exports.scrollPage = async (ctx) => {
else
ctx.request.body.image = ""
var user = ctx.request.body; //require user id
var page = ctx.request.body;
try {
const mybook = await Book.findOne({ _id: book._id });
mybook.updateP(book);
ctx.body = user._id;
} catch (e) {
const mypage = await Page.findOne({ _id: page._id });//require page's _id
if(ctx.state.user._id == mypage.author){
mypage.updateP(book);
ctx.body = mypage;
console.log(mypage);
ctx.status = 200;}
} catch (e) {
ctx.throw(500, e);
}
ctx.body = user._id;
console.log(user);
ctx.body = {
message: "작성자가 아닙니다. " }
}
ctx.status = 200;
};
......@@ -178,18 +188,3 @@ exports.deletePage = async (ctx) => {
}
ctx.status = 204; // No Content
};
exports.getPage = async (ctx) => {
const pageid = ctx.request.body._id;
try {
const mypage = await Book.findById(pageid).exec();
const user = await User.findById(mypage.author).exec();//작가정보
const author_name = user.nickname;
ctx.body = {mypage,author_name:author_name}
console.log(mypage)
} catch (e) {
ctx.throw(500, e);
}
};
......
$(function(){
function get2digits (num){
return ('0' + num).slice(-2);
}
function getDate(dateObj){
if(dateObj instanceof Date)
return dateObj.getFullYear() + '-' + get2digits(dateObj.getMonth()+1)+ '-' + get2digits(dateObj.getDate());
}
function getTime(dateObj){
if(dateObj instanceof Date)
return get2digits(dateObj.getHours()) + ':' + get2digits(dateObj.getMinutes())+ ':' + get2digits(dateObj.getSeconds());
}
function convertDate(){
$('[data-date]').each(function(index,element){
var dateString = $(element).data('date');
if(dateString){
var date = new Date(dateString);
$(element).html(getDate(date));
}
});
}
function convertDateTime(){
$('[data-date-time]').each(function(index,element){
var dateString = $(element).data('date-time');
if(dateString){
var date = new Date(dateString);
$(element).html(getDate(date)+' '+getTime(date));
}
});
}
convertDate();
convertDateTime();
});
\ No newline at end of file
body {
font-family: 'Open Sans', sans-serif;
}
.breadcrumb-item {
font-size: 0.8em !important;
}
.ellipsis{
display: block;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis; /* 1 */
}
.board-table {
table-layout: fixed;
}
.board-table .date {
width: 100px;
}
.post-body{
white-space: pre-line; /* 2 */
}
.post-info{
font-size: 0.8em;
}
\ No newline at end of file
......@@ -9,8 +9,12 @@ const mongoose = require('mongoose');
const bodyParser = require('koa-bodyparser');
const port = process.env.PORT || 3000
//443
const passport = require('koa-passport')
const app = new Koa();
const router = new Router()
const render = require('koa-ejs');
const path = require('path');
const send = require('koa-send');
var options = {
key: fs.readFileSync('./server.key'),
......@@ -29,53 +33,72 @@ mongoose.connect(process.env.MONGO_URI).then(
console.error(e);
});
var readFileThunk = function(src) {
return new Promise(function (resolve, reject) {
fs.readFile(src, {'encoding': 'utf8'}, function (err, data) {
if(err) return reject(err);
resolve(data);
});
});
}
//app.use(router.routes())
/*
app
.use(router.routes())
.use(router.allowedMethods());
*/
app
.use(jwtMiddleware)
.use(bodyParser()) // bodyParser는 라우터 코드보다 상단에 있어야 합니다.
.use(router.routes())
.use(router.allowedMethods());
/*
router.get('/', (ctx, next) => {
ctx.body = '루트 페이지 입니다.';
render(app, {
root: path.join(__dirname, 'views'),
layout: false,
viewExt: 'ejs',
cache: false,
debug: true
});
// app.use(async function (ctx) {
// await ctx.render('home/welcome');
// });
app
.use(jwtMiddleware)
.use(bodyParser()) // bodyParser는 라우터 코드보다 상단에 있어야 합니다.
.use(router.routes())
.use(router.allowedMethods())
.use(passport.initialize());
router.get('/', async ctx =>{
await ctx.render('home/welcome');
});
*/
router.get('/about', async ctx =>{
await ctx.render('home/about');
});
router.get('/login', async ctx =>{
await ctx.render('users/index');
});
router.get('/signup', async ctx =>{
await ctx.render('users/new');
});
/*
router.get('/', async (ctx, next) => {
const rawContent = fs.readFileSync('index.html').toString('utf8')
ctx.body = rawContent
})*/
router.get('/', function *(){
this.body = yield readFileThunk(__dirname + '/public/index.html');
})
//router.use(api.routes());
//app.use(router.routes()).use(router.allowedMethods())
router.use('/api', api.routes());
app.use(router.routes()).use(router.allowedMethods());
//app.use(router.routes()).use(router.allowedMethods());
http2
.createSecureServer(options, app.callback())
.listen(port, () => console.log("listening on port %i", port));
//app.listen(port, function () {
//console.log('server listening on port %d', port);
//});
/*
app.listen(port, function () {
console.log('server listening on port %d', port);
});
*/
\ No newline at end of file
......
const config = {
mailer: {
user: "yoobinpark@khu.ac.kr",
password: "1q2w3e4r!@",
user: "like01test@gmail.com",
password: "like1412",
expiresIn: 60 * 5,
},
};
......
......@@ -5,9 +5,9 @@ const { Schema } = mongoose;
const bookSchema = new Schema({
id: mongoose.Schema.Types.ObjectId,//unique number of page
pages:[{type:String}],//book contains several pages. pages is the list of page id
pages:[{type:mongoose.Schema.Types.ObjectId, ref:'page', required:false}],//book contains several pages. pages is the list of page id
title: {type:String, require:true}, // book title
author: [{type:String, require:true, default:user.user}],//작가복수 가능
author: [{type:mongoose.Schema.Types.ObjectId, ref:'user', required:true}],//작가복수 가능
contents: {type:String}, // book subtitle or detail
createDate: {type:Date, require:true, default:Date.now},
updateDate: {type:Date, default:Date.now},
......@@ -102,5 +102,6 @@ const bookSchema = new Schema({
};
module.exports = mongoose.model("Book", bookSchema);
\ No newline at end of file
......
......@@ -4,9 +4,9 @@ const { Schema } = mongoose;
const PageSchema = new Schema({
id: mongoose.Schema.Types.ObjectId,//unique number of page
book:{type:String},//book contains several pages
book:[{type:mongoose.Schema.Types.ObjectId, ref:'book', required:false}],//book contains several pages
title: {type:String, require:true}, // title of post
author: [{type:String, require:true, default:user.user}],
author: [{type:mongoose.Schema.Types.ObjectId, ref:'user', required:true}],
contents: {type:String}, // contents of page
createDate: {type:Date, require:true, default:Date.now},
updateDate: {type:Date, default:Date.now},
......
......@@ -12,10 +12,10 @@ const UserSchema = new Schema({
password: String,
token: String,
//user info
username: String,
phone: {type: String, require: true},
nickname: {type: String, default: ""},
books: [{type: String}],//array of bookid
books: [{type:mongoose.Schema.Types.ObjectId, ref:'book', required:false}],//array of bookid
pages:[{type:mongoose.Schema.Types.ObjectId, ref:'page', required:false}],
favorite: [{ type: String }],//String of url(book, page)
});
......
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<nav aria-label="breadcrumb">
<ol class="breadcrumb p-1 pl-2 pr-2">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="/api/page">Board</a></li>
<li class="breadcrumb-item"><a href="/api/page/<%= page._id %>"><%= page.title %></a></li>
<li class="breadcrumb-item active" aria-current="page">Edit Post</li>
</ol>
</nav>
<form action="/api/page/<%= page._id %>?_method=put" method="post">
<div class="form-group">
<label for="title">Title</label>
<input type="text" id="title" name="title" value="<%= page.title %>" class="form-control">
</div>
<div class="form-group">
<label for="body">Body</label>
<textarea id="body" name="body" rows="5" class="form-control"><%= post.contents %></textarea>
</div>
<div>
<a class="btn btn-primary" href="/api/page/<%= page._id %>">Back</a>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<h2 class="mb-3">Board</h2>
<table class="board-table table table-sm border-bottom">
<thead class="thead-light">
<tr>
<th scope="col">Title</th>
<th scope="col" class="date">Date</th>
</tr>
</thead>
<tbody>
<% if(page == null || page.length == 0){ %>
<tr>
<td colspan=2> There is no data to show :( </td>
</tr>
<% } %>
<% page.forEach(function(page) { %>
<tr>
<td>
<a href="/api/page/<%= page._id %>"><div class="ellipsis"><%= page.title %></div></a>
</td>
<td class="date">
<span data-date="<%= page.createDate %>"></span> <!-- 1 -->
</td>
</tr>
<% }) %>
</tbody>
</table>
<div>
<a class="btn btn-primary" href="/api/page/new">New</a>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<nav aria-label="breadcrumb"> <!-- 1 -->
<ol class="breadcrumb p-1 pl-2 pr-2">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="/api/page">Board</a></li>
<li class="breadcrumb-item active" aria-current="page">New Post</li>
</ol>
</nav>
<form action="/api/page/" method="post">
<div class="form-group">
<label for="title">Title</label>
<input type="text" id="title" name="title" value="" class="form-control">
</div>
<div class="form-group">
<label for="body">Body</label>
<textarea id="body" name="body" rows="5" class="form-control"></textarea>
</div>
<div>
<a class="btn btn-primary" href="/api/page">Back</a>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<nav aria-label="breadcrumb">
<ol class="breadcrumb p-1 pl-2 pr-2">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="/api/book">Book</a></li>
<li class="breadcrumb-item active" aria-current="page"><%= page.title %></li>
</ol>
</nav>
<div class="card">
<h5 class="card-header p-2"><%= page.title %></h5>
<div class="row"> <!-- 1 -->
<div class="col-md-7 col-lg-8 col-xl-9 order-sm-2 order-md-1"> <!-- 1 -->
<div class="post-body p-2"><%= page.contents %></div>
</div>
<div class="col-md-5 col-lg-4 col-xl-3 order-sm-1 order-md-2"> <!-- 1 -->
<div class="post-info card m-2 p-2">
<div><span>Created</span> : <span data-date-time="<%= page.createDate %>"></span></div> <!-- 2 -->
<% if(page.updateDate) { %>
<div><span>Updated</span> : <span data-date-time="<%= page.updateDate %>"></span></div> <!-- 2 -->
<% } %>
</div>
</div>
</div>
</div>
<div class="mt-3">
<a class="btn btn-primary" href="/api/page">Back</a>
<a class="btn btn-primary" href="/api/page/<%= page._id %>/edit">Edit</a>
<form action="/api/page/<%= page._id %>?_method=delete" method="post" class="d-inline">
<a class="btn btn-primary" href="javascript:void(0)" onclick="confirm('Do you want to delete this?')?this.parentElement.submit():null;">Delete</a>
</form>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<h2 class="mb-3">About</h2>
<P>이 사이트는 Like Project 임시 페이지 입니다. </p>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container">
<h3 class="mb-3">Login</h3>
<form class="user-form" action="/login" method="post">
<div class="form-group row">
<label for="username" class="col-sm-3 col-form-label">Username</label>
<div class="col-sm-9">
<input type="text" id="username" name="username" value="<%= username %>" class="form-control <%= (errors.username)?'is-invalid':'' %>">
<% if(errors.username){ %>
<span class="invalid-feedback"><%= errors.username %></span>
<% } %>
</div>
</div>
<div class="form-group row">
<label for="password" class="col-sm-3 col-form-label">Password</label>
<div class="col-sm-9">
<input type="password" id="password" name="password" value="" class="form-control <%= (errors.password)?'is-invalid':'' %>">
<% if(errors.password){ %>
<span class="invalid-feedback"><%= errors.password %></span>
<% } %>
</div>
</div>
<% if(errors.login){ %>
<div class="invalid-feedback d-block"><%= errors.login %></div>
<% } %>
<div class="mt-3">
<input class="btn btn-primary" type="submit" value="Submit">
</div>
</form>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<div class="jumbotron">
<h1>My Website</h1>
<P>제 웹사이트를 방문해 주셔서 감사합니다!</p>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!-- views/partials/head.ejs -->
<meta name="viewport" content="width=device-width,initial-scale=1">
<!-- jquery & bootstrap -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- web font --> <!-- 1 -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans&display=swap" rel="stylesheet">
<!-- my css -->
<script src="/src/api/page/script.js"></script>
<title>My Website</title>
\ No newline at end of file
<nav class="navbar navbar-expand-sm navbar-light bg-light mb-3">
<div class="container">
<div class="navbar-brand"></a>Like</div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav">
<li class="nav-item"><a href="/" class="nav-link">Home</a></li>
<li class="nav-item"><a href="/about" class="nav-link">About</a></li>
<li class="nav-item"><a href="/api/book" class="nav-link">Book</a></li>
<li class="nav-item"><a href="/api/page" class="nav-link">Page</a></li>
</ul>
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a href="/api/auth" class="nav-link">Sign Up</a></li>
<li class="nav-item"><a href="/api/auth/new" class="nav-link">Login</a></li>
</ul>
</div>
</div>
</nav>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<nav aria-label="breadcrumb">
<ol class="breadcrumb p-1 pl-2 pr-2">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="/api/page">Board</a></li>
<li class="breadcrumb-item"><a href="/api/page/<%= page._id %>"><%= page.title %></a></li>
<li class="breadcrumb-item active" aria-current="page">Edit Post</li>
</ol>
</nav>
<form action="/api/page/<%= page._id %>?_method=put" method="post">
<div class="form-group">
<label for="title">Title</label>
<input type="text" id="title" name="title" value="<%= page.title %>" class="form-control">
</div>
<div class="form-group">
<label for="body">Body</label>
<textarea id="body" name="body" rows="5" class="form-control"><%= post.contents %></textarea>
</div>
<div>
<a class="btn btn-primary" href="/api/page/<%= page._id %>">Back</a>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</body>
</html>
\ No newline at end of file
<!-- views/posts/index.ejs -->
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<h2 class="mb-3">Board</h2>
<table class="board-table table table-sm border-bottom">
<thead class="thead-light">
<tr>
<th scope="col">Title</th>
<th scope="col" class="date">Date</th>
</tr>
</thead>
<tbody>
<% if(page == null || page.length == 0){ %>
<tr>
<td colspan=2> There is no data to show :( </td>
</tr>
<% } %>
<% page.forEach(function(page) { %>
<tr>
<td>
<a href="/api/page/<%= page._id %>"><div class="ellipsis"><%= page.title %></div></a>
</td>
<td class="date">
<span data-date="<%= page.createDate %>"></span> <!-- 1 -->
</td>
</tr>
<% }) %>
</tbody>
</table>
<div>
<a class="btn btn-primary" href="/api/page/new">New</a>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<nav aria-label="breadcrumb"> <!-- 1 -->
<ol class="breadcrumb p-1 pl-2 pr-2">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="/api/page">Board</a></li>
<li class="breadcrumb-item active" aria-current="page">New Post</li>
</ol>
</nav>
<form action="/api/page/" method="post">
<div class="form-group">
<label for="title">Title</label>
<input type="text" id="title" name="title" value="" class="form-control">
</div>
<div class="form-group">
<label for="body">Body</label>
<textarea id="body" name="body" rows="5" class="form-control"></textarea>
</div>
<div>
<a class="btn btn-primary" href="/api/page">Back</a>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<nav aria-label="breadcrumb">
<ol class="breadcrumb p-1 pl-2 pr-2">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="/api/book">Book</a></li>
<li class="breadcrumb-item active" aria-current="page"><%= page.title %></li>
</ol>
</nav>
<div class="card">
<h5 class="card-header p-2"><%= page.title %></h5>
<div class="row"> <!-- 1 -->
<div class="col-md-7 col-lg-8 col-xl-9 order-sm-2 order-md-1"> <!-- 1 -->
<div class="post-body p-2"><%= page.contents %></div>
</div>
<div class="col-md-5 col-lg-4 col-xl-3 order-sm-1 order-md-2"> <!-- 1 -->
<div class="post-info card m-2 p-2">
<div><span>Created</span> : <span data-date-time="<%= page.createDate %>"></span></div> <!-- 2 -->
<% if(page.updateDate) { %>
<div><span>Updated</span> : <span data-date-time="<%= page.updateDate %>"></span></div> <!-- 2 -->
<% } %>
</div>
</div>
</div>
</div>
<div class="mt-3">
<a class="btn btn-primary" href="/api/page">Back</a>
<a class="btn btn-primary" href="/api/page/<%= page._id %>/edit">Edit</a>
<form action="/api/page/<%= page._id %>?_method=delete" method="post" class="d-inline">
<a class="btn btn-primary" href="javascript:void(0)" onclick="confirm('Do you want to delete this?')?this.parentElement.submit():null;">Delete</a>
</form>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<h3 class="mb-3">Edit User</h3>
<form action="/api/auth/users/<%= user.username %>?_method=put" method="post">
<div class="form-group row">
<label for="currentPassword" class="col-sm-3 col-form-label">Current Password*</label>
<div class="col-sm-9 col-sm-offset-3">
<input type="password" id="currentPassword" name="currentPassword" value="" class="form-control">
</div>
</div>
<hr></hr>
<div class="form-group row">
<label for="username" class="col-sm-3 col-form-label">Username*</label>
<div class="col-sm-9">
<input type="text" id="username" name="username" value="<%= user.nickname %>" class="form-control">
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-3 col-form-label">Name*</label>
<div class="col-sm-9">
<input type="text" id="name" name="name" value="<%= user.email %>" class="form-control">
</div>
</div>
<div class="form-group row">
<label for="email" class="col-sm-3 col-form-label">Email</label>
<div class="col-sm-9">
<input type="text" id="email" name="email" value="<%= user.email %>" class="form-control">
</div>
</div>
<div class="form-group row">
<label for="newPassword" class="col-sm-3 col-form-label">New Password</label>
<div class="col-sm-9 col-sm-offset-3">
<input type="password" id="newPassword" name="newPassword" value="" class="form-control">
</div>
</div>
<div class="form-group row">
<label for="passwordConfirmation" class="col-sm-3 col-form-label">Password Confirmation</label>
<div class="col-sm-9 col-sm-offset-3">
<input type="password" id="passwordConfirmation" name="passwordConfirmation" value="" class="form-control">
</div>
</div>
<p>
<small>*Required</small>
</p>
<div class="buttons">
<a class="btn btn-primary" href="/api/auth/users/<%= user.username %>">Back</a>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<h3 class="mb-3">Users</h3>
<ul class="list-group">
<% if(user == null || user.length == 0){ %>
<li class="list-group-item"> There is no user yet.</li>
<% } %>
<% user.forEach(function(user) { %>
<li class="list-group-item">
<a href="/api/auth/userlist/<%= user._id %>"><%= user.nickname %></a>
</li>
<% }) %>
</ul>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<h3 class="contentBoxTop mb-3">New User</h3>
<form action="/api/auth/signin" method="post">
<div class="form-group row">
<label for="nickname" class="col-sm-3 col-form-label">Username*</label>
<div class="col-sm-9">
<input type="text" id="nickname" name="nickname" value="" class="form-control">
</div>
</div>
<div class="form-group row">
<label for="email" class="col-sm-3 col-form-label">Email</label>
<div class="col-sm-9">
<input type="text" id="email" name="email" value="" class="form-control">
</div>
</div>
<div class="form-group row">
<label for="password" class="col-sm-3 col-form-label">Password*</label>
<div class="col-sm-9">
<input type="password" id="password" name="password" value="" class="form-control">
</div>
</div>
<div class="form-group row">
<label for="passwordConfirmation" class="col-sm-3 col-form-label">Password Confirmation*</label>
<div class="col-sm-9 col-sm-offset-3">
<input type="password" id="passwordConfirmation" name="passwordConfirmation" value="" class="form-control">
</div>
</div>
<p>
<small>*Required</small>
</p>
<div class="form-group">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<%- include('../partials/head') %>
</head>
<body>
<%- include('../partials/nav') %>
<div class="container mb-3">
<h3 class="contentBoxTop"><%= user.nickname</h3>
<form class="user-form" action="/users" method="post">
<fieldset disabled>
<div class="form-group row">
<label for="name" class="col-sm-3 col-form-label">Name</label>
<div class="col-sm-9">
<input class="form-control" type="text" id="name" name="name" value="<%= user.name %>">
</div>
</div>
<div class="form-group row">
<label for="email" class="col-sm-3 col-form-label">Email</label>
<div class="col-sm-9">
<input class="form-control" type="text" id="email" name="email" value="<%= user.email %>">
</div>
</div>
</fieldset>
</form>
<div>
<a class="btn btn-primary" href="/api/auth/users">Back</a>
<a class="btn btn-primary" href="/api/auth/users/<%= user.email %>/edit">Edit</a>
<form action="/users/<%= user.email %>?_method=delete" method="post" class="d-inline">
<a class="btn btn-primary" href="javascript:void(0)" onclick="confirm('Do you want to delete this?')?this.parentElement.submit():null;">Delete</a>
</form>
</div>
</div>
</body>
</html>
\ No newline at end of file