-1
나는 node.js에 웹 사이트를 작성하고 있습니다. 현재 순간에 나는 웹 사이트를 실행할 때마다 로그인 컨트롤러가로드되고 영원히로드됩니다.NODE.JS 익스프레스 웹 사이트 라우팅 오류가 있습니다.
페이지를로드 할 때 로그인 컨트롤러가로드되는 것을 원하지 않습니다. 내 버튼 로그인을 클릭 할 때로드해야합니다.
이 내 Router.js
module.exports = function(app) {
app.get('/login/:username/:password', function(req, res) {
var login = require('../controllers/login');
login.userLogin
});
app.get('/', function(req, res, next) {
res.render('index', {
title: 'Trace User Login'
});
});
}
이것은 내가 로그인 버튼을 클릭 한 번만 부하에 로그인 모듈을 받고 가야합니까 어떻게 내 옥 페이지
extends layout
block content
div#login
label#lblInfo Please enter your username and password.
input#txtUsername.form-control.login(placeholder='Username', type='text')
input#txtPassword.form-control.login(placeholder='Password', type='password')
a#btnLogin.btn.btn-danger.btn-lg(href='#') Login
block endContent
div.footer
p#dev Developed by :
a.redtextheadingsmall(href="http://www.verishare.co.za/", target="_blank") VeriShare
p Telephone: +27 (18) 294 1000 Fax: +27 (18) 294 3880 Email:
a.redtextheadingsmall(href="mailto:[email protected]") [email protected]
p We recommend that you view this website with: MS IE 10+ or Google Chrome 20.0+ or Mozilla 20.0+
p#copy Copyright © 2014 .. All Rights Reserved.
입니다. 그냥 이건 내 문제를 해결하는 것 같았다
console.log('Inside controller');
exports.userLogin = function(request, respond){
var Connection = require('tedious').Connection;
var Request = require('tedious').Request;
var config = {
userName: 'username',
password: 'password',
server: 'localhost',
options: {
instanceName: 'instance',
database: 'tempdb'
}
};
var connection = new Connection(config);
connection.on('connect', function(err) {
if (err)
console.log(err);
else
var userName = request.params.username;
var password = request.params.password;
loginRequest(userName,password);
});
};
function loginRequest(Username,Password) {
request = new Request("sp_WT_ValidateUser", function(err, rowCount) {
if (err) {
console.log(err);
} else {
console.log(rowCount + ' rows');
}
});
request.addParameter('UserName', TYPES.VarChar, Username);
request.addParameter('Password', TYPES.VarChar, Password);
request.addOutputParameter('InvalidPasswordCounter', TYPES.VarChar);
request.on('row', function(columns) {
columns.forEach(function(column) {
console.dir(column);
});
console.log('');
});
connection.execSql(request);
}