Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TypeError: response.writeHead is not a function
- at C:UsersKaaDesktopNodeShopserver.js:88:22
- server.route({
- method: 'POST',
- path: '/login',
- config: {
- auth: {
- mode: 'try',
- strategy: 'session'
- },
- plugins: {
- 'hapi-auth-cookie': {
- redirectTo: false
- }
- },
- handler: function(request, response) {
- if (request.auth.isAuthenticated) {
- console.info('Already!');
- return res.redirect('/');
- }
- var username = request.payload.username;
- dbCouch.get('user_' + request.payload.username).then(function(data) {
- var user = data;
- var pass = data.password;
- if(!user) {
- return console.error('Can`t find user!');
- }
- var password = request.payload.password;
- return Bcrypt.compare(password, pass, function(err, isValid) {
- response.writeHead(200, {'Content-Type': 'text/plain'});
- response.write('Text');
- response.end('ok');
- });
- })
- .catch((err) => {
- response(Boom.notFound('User is not found!')).code(400);
- });
- }
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement