Skip to main content

Changing Password Requirements with SailsJS and Passport

Cross post from my employer's development blog:

If you perform an installation of [Passport][passport] with [SailsJS][sails] using the [Sails Passport Auth Generator][sails-generate-auth] you get several files in your app already configured for you. If you then use passport-local, you will already have a complexity requirement on the password. It defaults to requiring 8 characters minimum, letters, numbers, and symbols.

What if you want to change this requirement? In the generated model file `Passport.js`, you should see a line that says `provider   : { type: 'alphanumericdashed' },` and `password    : { type: 'string', minLength: 6 }`. The minLength is an easy and obvious change. What about the complexity requirement though? This stumped me for a bit. There doesn’t seem to be any mention of these keywords or providers on the Passport official site, nor anything in the [Passport-local repository][passport-local]. I believe I found the answer, they appear to be ORM validations from Sails itself. You can find a list [here][validations].

For my project, I simply switched to `alphanumeric` and I no longer need symbols in my passwords. I suppose anything on the list linked above should work. I didn’t try it but I suppose you could even set it to `ipv6` and require that every user’s password be a valid ipv6 formatted address. Not sure I would recommend that though.



Laura Bush said…
I just wanted to say this is an elegantly composed article as we have seen here. I got some knowledge from your article and also it is a significant article for us. Thanks for sharing an article like this.Buy Real passports online USA
Weston Parker said…
I am very thankful to you that you have shared this information with us. I got some different kind of knowledge from your web page, and it is really helpful for everyone. Thanks for share it. fake id maker south carolina
Great work! I am totally impressed with your work. I got some amazing ideas from your article. Thanks and keep sharing. 482 visa
shopfastnotes said…
It is a proficient article that you have shared here about fake Australian drivers license online I got some unique and valuable information from your article. Thankful to you for sharing this article here.
The information you've provided is quite useful. It's incredibly instructional because it provides some of the most useful information. Thank you for sharing about hassle free Russian Passport Renewal service in this blog.

Popular posts from this blog

Atari E3 2004 PAL digital press kit

Making note of some old swag. The Atari E3 2004 PAL digital press kit. See video for details.

No, Don't Move to Canada

The 2016 presidential election year is upon us Americans. As the parties narrow on a candidate, it feels as though the atmosphere manages to get even more polarized. Eventually we start hearing the stories from friends and family, to even celebrities, stating “If [candidate I hate] get’s elected, I’m moving to Canada!”. We then all laugh once candidate X is elected (especially if we were a fan) as said person(s) don’t move to Canada. Even though we know most people are not literally serious when they state this, I feel it highlights a bigger issue that we don’t talk about enough. Simply put, we place way too much importance on who holds the U.S. Presidential office. When we say “I’m moving to Canada”, we’re essentially saying that the fight is over, there is no hope, even though we don’t actually pack up our bags and move. Which indirectly is stating, that there’s nothing we can do as an individual or community. That out of all the issues America faces, no non-profit, grassroots or