Skip to content

Wrong number of parameters in signToken method #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
remicastaing opened this issue Jul 22, 2014 · 7 comments
Closed

Wrong number of parameters in signToken method #382

remicastaing opened this issue Jul 22, 2014 · 7 comments
Assignees
Labels
Milestone

Comments

@remicastaing
Copy link
Contributor

The method signToken from auth.service.js is always called with two parameters:

var token = signToken(req.user._id, req.user.role);

(in /app/templates/server/auth(auth)/local/index.js line 15 or in /app/templates/server/auth(auth)/auth.service.js line 68)

But the function just accepts one parameter:

/**
 * Returns a jwt token signed by the app secret
 */
function signToken(id) {
  return jwt.sign({ _id: id }, config.secrets.session, { expiresInMinutes: 60*5 });
}

Where are the informations user.id and user.role extrated out of the token and then used?

@remicastaing
Copy link
Contributor Author

I mean auth.service.js on server side.

@meeDamian
Copy link
Contributor

Good point. I'm currently rebuilding auth system, and I'll take that into account :).

@remicastaing
Copy link
Contributor Author

Is the information user.id somewhere extracted from the token and then used?

@meeDamian
Copy link
Contributor

Yes. I believe that's how jwt works.

If you have some spare time you can checkout my WIP on one-account here. Some things are in coffeescript, because that's faster for me, I'll convert it to vanilla JS a little bit later.

@remicastaing
Copy link
Contributor Author

I will take a look tomorrow. Sometimes I had to sleep. ;)

signtoken put the userID in the token. But I find no place where this userID is taken out.

@JaKXz JaKXz added the bug label Jul 24, 2014
@meeDamian
Copy link
Contributor

I believe it is addressed in #392

seanmheff added a commit to seanmheff/generator-angular-fullstack that referenced this issue Dec 8, 2014
Change the parameters passed into the signToken function. This change is
trivial and tidies up the code.

No breaking change. Fixes issue angular-fullstack#382
@Awk34 Awk34 modified the milestones: 2.1.0, 2.2.0 Jul 14, 2015
@Awk34 Awk34 self-assigned this Aug 5, 2015
Awk34 added a commit that referenced this issue Aug 5, 2015
add role as second parameter, and attach to jwt

closes #382
@kingcody
Copy link
Member

closed by #1131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants