GithubHelp home page GithubHelp logo

estrada9166 / server-authentication-next.js Goto Github PK

View Code? Open in Web Editor NEW
106.0 3.0 14.0 2.68 MB

JavaScript 100.00%
zeit nextjs demo nextjs-template jwt jwt-authentication jwt-token server-rendering server-side-rendering

server-authentication-next.js's Issues

Unexpected token (

While running this code without performing any changes, I am getting following error:

const isLoggedIn = async (req, res, next) => {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:383:7)
at startup (bootstrap_node.js:149:9)

Can you please tell me why is this so?

Question: Usage (API Authentication)

I've looked everywhere for a simple authentication sample, and this is the best I found! Thanks a million. I am new to next.js, so I need a little guide on how to use this sample.

How am I supposed to actually authenticate? Am I supposed to, for instance, use something like unfetch in the AuthService.js to perform an actual authentication? If that is the case, then createJWT method is not usable in such a scenario right?

Kindly advice me on how to actually connect this and authenticate using a separate authentication service/API.

Thank you

How to pass user data from verifyJWT to redux store?

Hi Alejandro, thanks a lot for your example. It helped me a lot. But I still have one open question. How can I pass data that I get from verifyJWT to redux store? For example, if I want to render user name or check roles in components.

Syntax error at the isLoggedIn function on npm run dev

Phil@Phil-PC MINGW64 /c/projects/server-authentication-next.js (master)
$ npm run dev

> [email protected] dev C:\projects\server-authentication-next.js
> node server.js

C:\projects\server-authentication-next.js\server.js:16
const isLoggedIn = async (req, res, next) => {
                         ^
SyntaxError: Unexpected token (
    at Object.exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:418:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:533:3

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
npm ERR! node v7.5.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] dev: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script 'node server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the authentication.jwt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs authentication.jwt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls authentication.jwt
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\projects\server-authentication-next.js\npm-debug.log

When I try start the server, i get the above message. any idea why? npm install did run through successfully from what I can tell too.

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.