SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Chap 1 - Authentication - Submit does nothing?

    Thank you for publishing this handy book. I'm completely new to node.js. Not even a programmer. Just trying to employ the latest & greatest tech for an app I've been meaning to build. Therefore, please excuse my idiocy as I ask this ?:
    When I click on the submit button for the 'authentication' example, nothing happens. The browser just keeps churning. This happens when I use the github source code as well. Note: I did change the creds for the MongoDB connection. Even tried with my own VPS installation of MongoDB. Same effect. I also created a '/signup' directory in the app.js folder in hopes that would cause the info to post. Anybody else experience this same problem? Please help. Don't want to get discouraged this early in the game. Thanks.

  2. #2
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi timpoppe, sorry to hear you have been having trouble. Quick question did you change all three of the following parameters?

    var username = ...
    var password = ...
    var address = ...

    If so, would you be able to post your code I'm sure we can get this quickly resolved

  3. #3
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah Bloody Hell. Me own fault. Wasn't putting in the proper creds. Thanks for responding so soon.

    Looking forward to working on the rest of the example tuts.

    Great book.

  4. #4
    SitePoint Member maryisbusy's Avatar
    Join Date
    Apr 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm having this problem as well but I've entered the user/password/address info. I noticed in the example code there's a space before the address string. I am not able to run node app with this space. I get the same 'browser churning'.

  5. #5
    SitePoint Member maryisbusy's Avatar
    Join Date
    Apr 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    after reading another thread, I'm going to try a local install of MongoDB to see if it's a firewall issue.

  6. #6
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by maryisbusy View Post
    I'm having this problem as well but I've entered the user/password/address info. I noticed in the example code there's a space before the address string. I am not able to run node app with this space. I get the same 'browser churning'.
    The space before the "@" symbol for the address isn't supposed to be there, if you remove it, that ought to help.
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  7. #7
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'm seeing if the white space issue can be fixed up in the repository to avoid any future confusion. Any luck with the local install?

  8. #8
    SitePoint Member maryisbusy's Avatar
    Join Date
    Apr 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It was indeed a firewall issue, I got everything to work! Looking forward to continuing the book now. We are starting to use Node.js for more and more projects at work.

  9. #9
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Don, I just went thru chap 1 example. However, could not the the app.post portion to work.
    After filling out the form and hit submit, the browser return "Cannot GET /signup?username=john;password=1234".
    I did create the app.post section in the app.js just like the book.
    What do you think I did wrong?

    Thanks

  10. #10
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It looks like you don't have a route for /signup. Can you post your code and I will have a look

  11. #11
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    /**
    * Module dependencies.
    */

    var express = require('express')
    , routes = require('./routes')
    , fs = require('fs')
    , User = require('./models/User.js');

    var app = module.exports = express.createServer();

    // Configuration

    app.configure(function(){
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jade');
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.static(__dirname + '/public'));
    });

    app.configure('development', function(){
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
    });

    app.configure('production', function(){
    app.use(express.errorHandler());
    });

    // Routes

    app.get('/', routes.index);
    app.get('/form', function(req, res) {
    fs.readFile('./form.html', function(error, content) {
    if (error) {
    res.writeHead(500);
    res.end();
    }
    else {
    res.writeHead(200, { 'Content-Type': 'text/html' });
    res.end(content, 'utf-8');
    }
    });
    });

    // Post

    app.post('/signup', function(req, res) {
    var username = req.body.username;
    var password = req.body.password;
    User.addUser(username, password, function(err, user){
    if (err) throw err;
    res.redirect('/form');
    });
    });

    app.listen(3000);
    console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);

  12. #12
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    One other thing the following error message

    Cannot GET

    Looks a bit strange. In your form.html do you have method="POST" ?

  13. #13
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is my form.html:
    <form action="/signup" methond="post">
    <div>
    <label>Username/label>
    <input type="text" name="username"/><br />
    </div>
    <div>
    <label>Password/label>
    <input type="password" name="password" />
    </div>
    <div><input type="submit" value="Sign UP"/></div>
    </form>

  14. #14
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don, never mind.
    I just realized that I misspell "method".
    It's always the most obvious.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •