손장민

Bug Fixed, Login Success

...@@ -15,10 +15,22 @@ let PostSchema = { ...@@ -15,10 +15,22 @@ let PostSchema = {
15 } 15 }
16 }; 16 };
17 17
18 +let UserSchema = {
19 + name: 'User',
20 + properties: {
21 + id: 'string',
22 + pw: 'string',
23 + name: 'string'
24 + }
25 +};
18 var blogRealm = new Realm({ 26 var blogRealm = new Realm({
19 path: 'blog.realm', 27 path: 'blog.realm',
20 schema: [PostSchema] 28 schema: [PostSchema]
21 }); 29 });
30 +var userRealm = new Realm({
31 + path: 'user.realm',
32 + schema: [UserSchema]
33 +});
22 34
23 app.use(bodyParser.urlencoded({extended: true})); 35 app.use(bodyParser.urlencoded({extended: true}));
24 36
...@@ -32,14 +44,41 @@ app.get('/main', function(req, res) { ...@@ -32,14 +44,41 @@ app.get('/main', function(req, res) {
32 // res.sendFile(__dirname + "/write.html"); 44 // res.sendFile(__dirname + "/write.html");
33 res.sendFile(__dirname+"/pages/main.html"); 45 res.sendFile(__dirname+"/pages/main.html");
34 }); 46 });
47 +
35 app.get('/login', function(req, res) { 48 app.get('/login', function(req, res) {
36 // res.sendFile(__dirname + "/write.html"); 49 // res.sendFile(__dirname + "/write.html");
37 res.sendFile(__dirname+"/pages/login.html"); 50 res.sendFile(__dirname+"/pages/login.html");
38 }); 51 });
52 +app.post('/login', function(req, res) {
53 + let chk = false;
54 + let id = req.body['id'],
55 + pw = req.body['pw'],
56 + users = userRealm.objects('User');
57 + for(var i = 0 ; i<users.length; i++)
58 + {
59 + if(id==users[i].id && pw ==users[i].pw)
60 + {
61 + chk = true;
62 + }
63 + }
64 + ///실패
65 + if(chk ==false)
66 + {
67 + console.log("계정을 확인해주세요");
68 + }
69 + else {
70 + res.sendFile(__dirname + "/main2.html");
71 + }
72 +});
73 +
39 app.get('/register', function(req, res) { 74 app.get('/register', function(req, res) {
40 // res.sendFile(__dirname + "/write.html"); 75 // res.sendFile(__dirname + "/write.html");
41 res.sendFile(__dirname+"/pages/register.html"); 76 res.sendFile(__dirname+"/pages/register.html");
42 }); 77 });
78 +app.get('/logout', function(req, res) {
79 +// res.sendFile(__dirname + "/write.html");
80 +res.sendFile(__dirname+"/intro.html");
81 +});
43 app.get('/info', function(req, res) { 82 app.get('/info', function(req, res) {
44 // res.sendFile(__dirname + "/write.html"); 83 // res.sendFile(__dirname + "/write.html");
45 res.sendFile(__dirname+"/pages/info.html"); 84 res.sendFile(__dirname+"/pages/info.html");
...@@ -54,7 +93,15 @@ app.post('/write', function(req, res) { ...@@ -54,7 +93,15 @@ app.post('/write', function(req, res) {
54 }); 93 });
55 res.sendFile(__dirname + "/write-complete.html"); 94 res.sendFile(__dirname + "/write-complete.html");
56 }); 95 });
57 - 96 +app.post('/register', function(req, res) {
97 + let id = req.body['id'],
98 + pw = req.body['pw'],
99 + name = req.body['name']
100 + userRealm.write(() => {
101 + userRealm.create('User', {id: id, pw: pw, name: name});
102 + });
103 + res.sendFile(__dirname + "/write-complete.html");
104 +});
58 app.listen(3000, function() { 105 app.listen(3000, function() {
59 console.log("Go!"); 106 console.log("Go!");
60 }); 107 });
......
No preview for this file type
...@@ -50,13 +50,13 @@ ...@@ -50,13 +50,13 @@
50 <h3 class="panel-title">Please Sign In</h3> 50 <h3 class="panel-title">Please Sign In</h3>
51 </div> 51 </div>
52 <div class="panel-body"> 52 <div class="panel-body">
53 - <form role="form"> 53 + <form action="/login" method="POST">
54 <fieldset> 54 <fieldset>
55 <div class="form-group"> 55 <div class="form-group">
56 - <input class="form-control" placeholder="E-mail" name="email" type="email" autofocus> 56 + <input class="form-control" placeholder="ID" name="id" type="name" autofocus>
57 </div> 57 </div>
58 <div class="form-group"> 58 <div class="form-group">
59 - <input class="form-control" placeholder="Password" name="password" type="password" value=""> 59 + <input class="form-control" placeholder="Password" name="pw" type="password" value="">
60 </div> 60 </div>
61 <div class="checkbox"> 61 <div class="checkbox">
62 <label> 62 <label>
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
64 </label> 64 </label>
65 </div> 65 </div>
66 <!-- Change this to a button or input when using this as a form --> 66 <!-- Change this to a button or input when using this as a form -->
67 - <a href="/" class="btn btn-lg btn-success btn-block">Login</a> 67 + <button type="submit" class="btn btn-lg btn-success btn-block">Login</button>
68 <a href="/register" class="btn btn-lg btn-success btn-block">Register</a> 68 <a href="/register" class="btn btn-lg btn-success btn-block">Register</a>
69 </fieldset> 69 </fieldset>
70 </form> 70 </form>
......
...@@ -85,7 +85,6 @@ ...@@ -85,7 +85,6 @@
85 </nav> 85 </nav>
86 86
87 <div class="container"> 87 <div class="container">
88 - background-color:Red;
89 <!-- Main component for a primary marketing message or call to action --> 88 <!-- Main component for a primary marketing message or call to action -->
90 <div class="jumbotron"> 89 <div class="jumbotron">
91 <h1>KHU- Coin Community</h1> 90 <h1>KHU- Coin Community</h1>
......
1 +<!DOCTYPE html>
2 +<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
3 +
4 +<!-- 부가적인 테마 -->
5 +<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
6 +
7 +<!-- 합쳐지고 최소화된 최신 자바스크립트 -->
8 +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
9 +<html lang="en">
10 +
11 +
12 +
13 +
14 +<head>
15 + <meta charset="utf-8">
16 + <meta http-equiv="X-UA-Compatible" content="IE=edge">
17 + <meta name="viewport" content="width=device-width, initial-scale=1">
18 + <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
19 + <meta name="description" content="">
20 + <meta name="author" content="">
21 + <link rel="icon" href="../../favicon.ico">
22 +
23 + <title>Coin Community</title>
24 +
25 + <!-- Bootstrap core CSS -->
26 + <link href="../../dist/css/bootstrap.min.css" rel="stylesheet">
27 +
28 + <!-- Custom styles for this template -->
29 + <link href="navbar-fixed-top.css" rel="stylesheet">
30 +
31 + <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
32 + <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
33 + <script src="../../assets/js/ie-emulation-modes-warning.js"></script>
34 +
35 + <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
36 + <!--[if lt IE 9]>
37 + <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
38 + <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
39 + <![endif]-->
40 +</head>
41 +<style>
42 +<body>
43 + background-image: url("background.jpg");
44 + background-color: #cccccc;
45 + </style>
46 + <style type = "text/css">
47 + .jumbotron{
48 + background-image: url('images/background.jpg');
49 + background-size: cover;
50 + text-shadow: black 0.1em 0.1em 0.1em;
51 + color: whites;
52 + }
53 + </style>
54 + <!-- Fixed navbar -->
55 + <nav class="navbar navbar-default">
56 + <div class="container-fluid">
57 + <!-- Brand and toggle get grouped for better mobile display -->
58 + <div class="navbar-header">
59 + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
60 + <span class="sr-only">Toggle navigation</span>
61 + <span class="icon-bar"></span>
62 + <span class="icon-bar"></span>
63 + <span class="icon-bar"></span>
64 + </button>
65 + <a class="navbar-brand" href="#">Coin Community</a>
66 + </div>
67 +
68 + <!-- Collect the nav links, forms, and other content for toggling -->
69 + <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
70 + <ul class="nav navbar-nav">
71 + <!--<li class="active"><a href="#">View Chart <span class="sr-only">(current)</span></a></li>
72 + <li><a href="#">Freeboard</a></li>-->
73 +
74 + </ul>
75 +
76 + <ul class="nav navbar-nav navbar-right">
77 + <li><a href="/login">Login</a></li>
78 + <li><a href="/info">About me</a></li>
79 +
80 + </ul>
81 + </div>
82 + <!-- /.navbar-collapse -->
83 + </div>
84 + <!-- /.container-fluid -->
85 + </nav>
86 +
87 + <div class="container">
88 +
89 +
90 +
91 + <div class="col-lg-12">
92 + <div class="panel panel-default">
93 + <div class="panel-heading">
94 + Line Chart Example
95 +
96 + <script src="https://mining-profit.com/js/mp-btc-chart.js"></script>
97 + <script type="text/javascript">
98 + MiningProfitBTCChart.setChartWidth(1070);
99 + MiningProfitBTCChart.setChartHeight(500);
100 + MiningProfitBTCChart.isDisplayControlRanges(true);
101 + MiningProfitBTCChart.isDisplayControlInterval(false);
102 + MiningProfitBTCChart.setInitialRange('20h');
103 + MiningProfitBTCChart.setChartRanges(['6h', '10h', '20h', '2d', '1w', '2w', '1m']);
104 + MiningProfitBTCChart.setChartExchanges([{mpvaluation: '#428bca'}, {bitstamp: '#B4CD3E'}, {coinbase: '#D54E88'}, {btce: '#F0522B'}]);
105 + MiningProfitBTCChart.setInitialExchange('coinbase');
106 + MiningProfitBTCChart.setMajorColor('rgb(35, 119, 58)');
107 + MiningProfitBTCChart.draw();
108 + </script>
109 + </div>
110 + <!-- /.panel-heading -->
111 + <div class="panel-body">
112 + <div class="flot-chart">
113 + <div class="flot-chart-content" id="flot-line-chart"></div>
114 + </div>
115 + </div>
116 + <!-- /.panel-body -->
117 + </div>
118 + <!-- /.panel -->
119 + </div>
120 +
121 + </div>
122 + <!-- /container -->
123 +
124 + <!-- Bootstrap core JavaScript
125 + ================================================== -->
126 + <!-- Placed at the end of the document so the pages load faster -->
127 + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
128 + <script src="../../dist/js/bootstrap.min.js"></script>
129 + <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
130 + <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
131 + <script scr="https://code.jquery.com/jquery-3.1.1.min.js"></script>
132 + <script src="js/bootstrap.js"></script>
133 +</body>
134 +
135 +</html>
...@@ -50,13 +50,13 @@ ...@@ -50,13 +50,13 @@
50 <h3 class="panel-title">Register</h3> 50 <h3 class="panel-title">Register</h3>
51 </div> 51 </div>
52 <div class="panel-body"> 52 <div class="panel-body">
53 - <form role="form"> 53 + <form action="/register" method="POST">
54 <fieldset> 54 <fieldset>
55 <div class="form-group"> 55 <div class="form-group">
56 - <input class="form-control" placeholder="E-mail" name="email" type="email" autofocus> 56 + <input class="form-control" placeholder="E-mail" name="id" type="name" autofocus>
57 </div> 57 </div>
58 <div class="form-group"> 58 <div class="form-group">
59 - <input class="form-control" placeholder="Password" name="password" type="password" value=""> 59 + <input class="form-control" placeholder="Password" name="pw" type="password" value="">
60 </div> 60 </div>
61 <div class="form-group"> 61 <div class="form-group">
62 <input class="form-control" placeholder="Confirm Password" name="password2" type="password2" value=""> 62 <input class="form-control" placeholder="Confirm Password" name="password2" type="password2" value="">
...@@ -65,8 +65,8 @@ ...@@ -65,8 +65,8 @@
65 <input class="form-control" placeholder="Name" name="name" type="name" value=""> 65 <input class="form-control" placeholder="Name" name="name" type="name" value="">
66 </div> 66 </div>
67 <!-- Change this to a button or input when using this as a form --> 67 <!-- Change this to a button or input when using this as a form -->
68 - <a href="/" class="btn btn-lg btn-success btn-block">Register</a> 68 + <button type="submit" class="btn btn-lg btn-success btn-block">Register</button>
69 - <a href="/" class="btn btn-lg btn-success btn-block">Cancel</a> 69 + <a href="/main" class="btn btn-lg btn-success btn-block">Cancel</a>
70 </fieldset> 70 </fieldset>
71 </form> 71 </form>
72 </div> 72 </div>
......
No preview for this file type
No preview for this file type