Commit 791c9a51 authored by 이재연's avatar 이재연
Browse files

signup data

parent ea8ae1a0
[0102/195101.790:ERROR:directory_reader_win.cc(43)] FindFirstFile: 지정된 경로를 찾을 수 없습니다. (0x3) [0102/195101.790:ERROR:directory_reader_win.cc(43)] FindFirstFile: 지정된 경로를 찾을 수 없습니다. (0x3)
[0104/152743.507:ERROR:directory_reader_win.cc(43)] FindFirstFile: 지정된 경로를 찾을 수 없습니다. (0x3)
...@@ -7,6 +7,7 @@ import option from '../option.svg'; ...@@ -7,6 +7,7 @@ import option from '../option.svg';
function MainNav() { function MainNav() {
function handleClick() { function handleClick() {
alert('로그아웃이 완료되었습니다.') alert('로그아웃이 완료되었습니다.')
window.location.href="/home"
} }
return ( return (
......
...@@ -22,7 +22,7 @@ function SubNav() { ...@@ -22,7 +22,7 @@ function SubNav() {
} }
return ( return (
<Navbar sticky="top" className="flex-nowrap" style={{ top: "62px", paddingTop: "0", paddingBottom: "0", backgroundColor: "#fff" }}> <Navbar sticky="top" className="flex-nowrap" style={{ top: "62px", paddingTop: "0", paddingBottom: "0", backgroundColor: "#fff", overflowX: "auto" }}>
<style type="text/css"> <style type="text/css">
{` {`
.nav-link, .nav-link:hover, .nav-link:active { .nav-link, .nav-link:hover, .nav-link:active {
......
...@@ -100,12 +100,12 @@ function Signup() { ...@@ -100,12 +100,12 @@ function Signup() {
<Form.Row> <Form.Row>
<Col sm={4} xs={6} as={Form.Label} for="number">주민등록번호</Col> <Col sm={4} xs={6} as={Form.Label} for="number">주민등록번호</Col>
<Col as={Row} sm={8} xs={12} > <Col as={Row} sm={8} xs={10} >
<Form.Control <Form.Control
required type="text" required type="text"
name="number1" name="number1"
maxlength="6" maxlength="6"
className="mx-2" style={{ width: '170px' }} className="mx-2" style={{ width: '17 0px' }}
value={user.number1} value={user.number1}
onChange={handleChange}> onChange={handleChange}>
</Form.Control> </Form.Control>
...@@ -114,7 +114,7 @@ function Signup() { ...@@ -114,7 +114,7 @@ function Signup() {
required type="text" required type="text"
name="number2" name="number2"
maxlength="1" className="mx-3" maxlength="1" className="mx-3"
style={{ width: '25px' }} style={{ width: '50px' }}
value={user.number2} value={user.number2}
onChange={handleChange}> onChange={handleChange}>
</Form.Control> </Form.Control>
......
...@@ -33,7 +33,7 @@ app.use(express.json()); ...@@ -33,7 +33,7 @@ app.use(express.json());
// app.listen(port, () => console.log(port)); // app.listen(port, () => console.log(port));
app.listen(3001, () => console.log('Listenning')); app.listen(3001, () => console.log('Listenning'));
app.use(userRouter) app.use('/api/users',userRouter)
// catch 404 and forward to error handler // catch 404 and forward to error handler
// app.use(function(req, res, next) { // app.use(function(req, res, next) {
......
...@@ -2,14 +2,17 @@ import User from "../models/User.js"; ...@@ -2,14 +2,17 @@ import User from "../models/User.js";
import isLength from 'validator/lib/isLength.js' import isLength from 'validator/lib/isLength.js'
const signup = async (req, res) => { const signup = async (req, res) => {
const { name, number,id, password,password2,tel } = req.body console.log(req.body)
console.log('req.body.name=', req.body.name)
const { name, number1, number2, id, password, password2, tel } = req.body
try { try {
if(!isLength(password,{min:8, max:15})){ if(!isLength(password,{min:8, max:15})){
return res.status(422).send('비밀번호는 8-15자리로 입력해주세요.') return res.status(422).json({message: '비밀번호는 8-15자리로 입력해주세요.'})
} }
const newUser = await new User ({ const newUser = await new User ({
name, name,
number, number1,
number2,
id, id,
password, password,
password2, password2,
...@@ -20,7 +23,7 @@ const signup = async (req, res) => { ...@@ -20,7 +23,7 @@ const signup = async (req, res) => {
} catch (error) { } catch (error) {
console.log(error) console.log(error)
res.status(500).send('죄송합니다. 다시 입력해 주십시오.') res.status(500).json({message:'죄송합니다. 다시 입력해 주십시오.'})
} }
} }
......
...@@ -15,12 +15,15 @@ const UserSchema = new mongoose.Schema({ ...@@ -15,12 +15,15 @@ const UserSchema = new mongoose.Schema({
password: { password: {
type: String, type: String,
required: true, required: true,
select: true,
}, },
number:{ number1:{
type:String,
required:true,
unique:true
},
number2:{
type:String, type:String,
required:true, required:true,
select:true,
unique:true unique:true
}, },
tel:{ tel:{
......
...@@ -3,7 +3,7 @@ import userCtrl from '../controllers/user.controller.js'; ...@@ -3,7 +3,7 @@ import userCtrl from '../controllers/user.controller.js';
const router = express.Router() const router = express.Router()
router.route('/api/users/signup') router.route('/signup')
.post(userCtrl.signup) .post(userCtrl.signup)
.get(userCtrl.hello) .get(userCtrl.hello)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment