Giter Site home page Giter Site logo

Comments (3)

geekyme avatar geekyme commented on May 4, 2024

why is this closed? I just cloned the repository and simulated the problem by deleting session cookies in the browser right before I create an article.
This results in the above middleware catching and making the call to "return res.redirect('/login')). However, the browser does not do a proper redirect to /login as expected.

Browser redirected to http://localhost:3000/#!/articles/undefined

the is the stack trace:

 
CastError: Cast to ObjectId failed for value "undefined" at path "_id"
    at ObjectId.cast (C:\Users\shawnlim\Documents\Websites\angularjs\mean\node_m
odules\mongoose\lib\schema\objectid.js:116:13)
    at ObjectId.castForQuery (C:\Users\shawnlim\Documents\Websites\angularjs\mea
n\node_modules\mongoose\lib\schema\objectid.js:165:17)
    at Query.cast (C:\Users\shawnlim\Documents\Websites\angularjs\mean\node_modu
les\mongoose\lib\query.js:412:32)
    at Query.findOne (C:\Users\shawnlim\Documents\Websites\angularjs\mean\node_m
odules\mongoose\lib\query.js:1762:10)
    at Query.exec (C:\Users\shawnlim\Documents\Websites\angularjs\mean\node_modu
les\mongoose\lib\query.js:171:16)
    at Function.ArticleSchema.statics.load (C:\Users\shawnlim\Documents\Websites
\angularjs\mean\app\models\article.js:41:29)
    at exports.article (C:\Users\shawnlim\Documents\Websites\angularjs\mean\app\
controllers\articles.js:14:13)
    at paramCallback (C:\Users\shawnlim\Documents\Websites\angularjs\mean\node_m
odules\express\lib\router\index.js:151:7)
    at param (C:\Users\shawnlim\Documents\Websites\angularjs\mean\node_modules\e
xpress\lib\router\index.js:133:11)
    at pass (C:\Users\shawnlim\Documents\Websites\angularjs\mean\node_modules\ex
press\lib\router\index.js:145:5)

how can the problem be solved?

from mean.

amoshaviv avatar amoshaviv commented on May 4, 2024

hey @geekyme, it was close because it was duplicate, i now added the duplicate label, i just pushed a fix to the authentication middleware that solves the entire issue.
The seed project didn't include angular so the authentication middleware behaved differently of what it should have.

from mean.

geekyme avatar geekyme commented on May 4, 2024

i just tried it, receiving a PUT http://localhost:3000/articles/522d7e1fc31738382f000004 401 (Unauthorized) in browser console log now when I deleted the session cookie.

Do I have to do a redirect to login page on the client side?

from mean.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.