Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Create an auth module using JWT #8

Closed
mesaugat opened this issue Jun 4, 2017 · 10 comments
Closed

Create an auth module using JWT #8

mesaugat opened this issue Jun 4, 2017 · 10 comments
Assignees

Comments

@mesaugat
Copy link
Owner

mesaugat commented Jun 4, 2017

No description provided.

@mesaugat mesaugat self-assigned this Oct 20, 2017
@duard
Copy link

duard commented Nov 15, 2017

What about authentication using Passport and JWT ?

@mesaugat
Copy link
Owner Author

I've already made some progress on that without using Passport. I just want to make a simple JWT authentication module. Anyone who wants to use Passport can then make changes as they want to.

@duard
Copy link

duard commented Nov 15, 2017

Could you merge the implementation of JWT to us ? I would like to see it.

@mesaugat
Copy link
Owner Author

But it should take some time. I don't have the time right now. I did it a few months back and need to look into it before merging.

@duard
Copy link

duard commented Nov 15, 2017

Ok, if you want, you could just share the code on gists.github.com

@mesaugat
Copy link
Owner Author

I've pushed some changes in the auth branch. Not sure if it works now but you can have a look. I'll try to do finish this in a few weeks.

@duard
Copy link

duard commented Nov 22, 2017

I'm trying to use yout util crypt functions ... how can I wait this Promise crypt.hash in my model ?

my User model :

  initialize() {
    this.on('creating', this.hashPassword);
  }
  hashPassword() {
    let pass = this.get('password');
    console.log(`=> my pass ${JSON.stringify(pass)}`);
    crypt.hash(pass).then(hash => {
      this.set('password', hash);
    })
  } 

@duard
Copy link

duard commented Nov 22, 2017

I change Utils crypt.has to

 hash(string) {
    let saltRounds = parseInt(process.env.AUTH_SALT_ROUNDS);
    const newPass = bcrypt.hashSync(string, saltRounds);
    console.log(`SALTS => ${saltRounds} ${string} ${newPass}`);
    return newPass
  },

and in my model

  hashPassword() {
    let pass = this.get('password');
    console.log(`Password Criptografado ${JSON.stringify(pass)}`);
    let newPass = crypt.hash(pass);
    console.log(`===> ${newPass}`);
    this.set('password', newPass);
  }

now it works;

@mesaugat
Copy link
Owner Author

It returns a Promise, you'll have to await or return bcrypt.hashSync as you have done.

@mesaugat
Copy link
Owner Author

Out of scope right now.

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

No branches or pull requests

2 participants