손장민

Bug Fixed, Login Success

......@@ -15,10 +15,22 @@ let PostSchema = {
}
};
let UserSchema = {
name: 'User',
properties: {
id: 'string',
pw: 'string',
name: 'string'
}
};
var blogRealm = new Realm({
path: 'blog.realm',
schema: [PostSchema]
});
var userRealm = new Realm({
path: 'user.realm',
schema: [UserSchema]
});
app.use(bodyParser.urlencoded({extended: true}));
......@@ -32,14 +44,41 @@ app.get('/main', function(req, res) {
// res.sendFile(__dirname + "/write.html");
res.sendFile(__dirname+"/pages/main.html");
});
app.get('/login', function(req, res) {
// res.sendFile(__dirname + "/write.html");
res.sendFile(__dirname+"/pages/login.html");
});
app.post('/login', function(req, res) {
let chk = false;
let id = req.body['id'],
pw = req.body['pw'],
users = userRealm.objects('User');
for(var i = 0 ; i<users.length; i++)
{
if(id==users[i].id && pw ==users[i].pw)
{
chk = true;
}
}
///실패
if(chk ==false)
{
console.log("계정을 확인해주세요");
}
else {
res.sendFile(__dirname + "/main2.html");
}
});
app.get('/register', function(req, res) {
// res.sendFile(__dirname + "/write.html");
res.sendFile(__dirname+"/pages/register.html");
});
app.get('/logout', function(req, res) {
// res.sendFile(__dirname + "/write.html");
res.sendFile(__dirname+"/intro.html");
});
app.get('/info', function(req, res) {
// res.sendFile(__dirname + "/write.html");
res.sendFile(__dirname+"/pages/info.html");
......@@ -54,7 +93,15 @@ app.post('/write', function(req, res) {
});
res.sendFile(__dirname + "/write-complete.html");
});
app.post('/register', function(req, res) {
let id = req.body['id'],
pw = req.body['pw'],
name = req.body['name']
userRealm.write(() => {
userRealm.create('User', {id: id, pw: pw, name: name});
});
res.sendFile(__dirname + "/write-complete.html");
});
app.listen(3000, function() {
console.log("Go!");
});
......
No preview for this file type
......@@ -50,13 +50,13 @@
<h3 class="panel-title">Please Sign In</h3>
</div>
<div class="panel-body">
<form role="form">
<form action="/login" method="POST">
<fieldset>
<div class="form-group">
<input class="form-control" placeholder="E-mail" name="email" type="email" autofocus>
<input class="form-control" placeholder="ID" name="id" type="name" autofocus>
</div>
<div class="form-group">
<input class="form-control" placeholder="Password" name="password" type="password" value="">
<input class="form-control" placeholder="Password" name="pw" type="password" value="">
</div>
<div class="checkbox">
<label>
......@@ -64,7 +64,7 @@
</label>
</div>
<!-- Change this to a button or input when using this as a form -->
<a href="/" class="btn btn-lg btn-success btn-block">Login</a>
<button type="submit" class="btn btn-lg btn-success btn-block">Login</button>
<a href="/register" class="btn btn-lg btn-success btn-block">Register</a>
</fieldset>
</form>
......
......@@ -85,7 +85,6 @@
</nav>
<div class="container">
background-color:Red;
<!-- Main component for a primary marketing message or call to action -->
<div class="jumbotron">
<h1>KHU- Coin Community</h1>
......
<!DOCTYPE html>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<!-- 부가적인 테마 -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<!-- 합쳐지고 최소화된 최신 자바스크립트 -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>Coin Community</title>
<!-- Bootstrap core CSS -->
<link href="../../dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="navbar-fixed-top.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="../../assets/js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<style>
<body>
background-image: url("background.jpg");
background-color: #cccccc;
</style>
<style type = "text/css">
.jumbotron{
background-image: url('images/background.jpg');
background-size: cover;
text-shadow: black 0.1em 0.1em 0.1em;
color: whites;
}
</style>
<!-- Fixed navbar -->
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Coin Community</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<!--<li class="active"><a href="#">View Chart <span class="sr-only">(current)</span></a></li>
<li><a href="#">Freeboard</a></li>-->
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="/login">Login</a></li>
<li><a href="/info">About me</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<div class="container">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Line Chart Example
<script src="https://mining-profit.com/js/mp-btc-chart.js"></script>
<script type="text/javascript">
MiningProfitBTCChart.setChartWidth(1070);
MiningProfitBTCChart.setChartHeight(500);
MiningProfitBTCChart.isDisplayControlRanges(true);
MiningProfitBTCChart.isDisplayControlInterval(false);
MiningProfitBTCChart.setInitialRange('20h');
MiningProfitBTCChart.setChartRanges(['6h', '10h', '20h', '2d', '1w', '2w', '1m']);
MiningProfitBTCChart.setChartExchanges([{mpvaluation: '#428bca'}, {bitstamp: '#B4CD3E'}, {coinbase: '#D54E88'}, {btce: '#F0522B'}]);
MiningProfitBTCChart.setInitialExchange('coinbase');
MiningProfitBTCChart.setMajorColor('rgb(35, 119, 58)');
MiningProfitBTCChart.draw();
</script>
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<div class="flot-chart">
<div class="flot-chart-content" id="flot-line-chart"></div>
</div>
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
</div>
<!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="../../dist/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
<script scr="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.js"></script>
</body>
</html>
......@@ -50,13 +50,13 @@
<h3 class="panel-title">Register</h3>
</div>
<div class="panel-body">
<form role="form">
<form action="/register" method="POST">
<fieldset>
<div class="form-group">
<input class="form-control" placeholder="E-mail" name="email" type="email" autofocus>
<input class="form-control" placeholder="E-mail" name="id" type="name" autofocus>
</div>
<div class="form-group">
<input class="form-control" placeholder="Password" name="password" type="password" value="">
<input class="form-control" placeholder="Password" name="pw" type="password" value="">
</div>
<div class="form-group">
<input class="form-control" placeholder="Confirm Password" name="password2" type="password2" value="">
......@@ -65,8 +65,8 @@
<input class="form-control" placeholder="Name" name="name" type="name" value="">
</div>
<!-- Change this to a button or input when using this as a form -->
<a href="/" class="btn btn-lg btn-success btn-block">Register</a>
<a href="/" class="btn btn-lg btn-success btn-block">Cancel</a>
<button type="submit" class="btn btn-lg btn-success btn-block">Register</button>
<a href="/main" class="btn btn-lg btn-success btn-block">Cancel</a>
</fieldset>
</form>
</div>
......
No preview for this file type
No preview for this file type