rnadler / ng2-password-strength-bar

Angular 2/4/5 Password Strength Bar
http://bobonmedicaldevicesoftware.com/blog/2016/12/09/publishing-an-angular-2-component-npm-package/
MIT License
20 stars 17 forks source link

Add tslint config, fix invalid css, add option to set custom bar colors #19

Closed btxtiger closed 6 years ago

rnadler commented 6 years ago

Thanks @btxtiger! Please take a look at the changes I made on the btxtiger-master branch. If you don't have further comments I will merge and push the new version to npm.

btxtiger commented 6 years ago

Hi, I have two questions: 1) What is the barColorsChecked boolean used for? Should it prevent the colors to be changed more than once? But what if the first try fails for whatever reason? 2) src/passwordStrengthBar.component.ts:59 I'm not sure if here isn't created a reference. this.colors = this.barColors;

If we write it this way:

var k = [1,2,3,4,5];
var b = [3,3,3,3,3];
var b = k;
b[0] = 99
// Output b: [99, 2, 3, 4, 5]
// Output k: [99, 2, 3, 4, 5]

I'm still not that familiar with ES6 classes, so it might be possible assigning this way this.colors = this.barColors; might be correct. If it is a reference, this.barColors is changeable on the flow if this.myColors is updated. That would mean there isn't a secure working fallback if myColors becomes undefined for whatever reason. That's why I used this.colors = this.barColors.slice();here.

rnadler commented 6 years ago

I originally assumed that the check only needed to be done once. It doesn't seem like a common use case, but there's nothing preventing the client from dynamically changing the colors. I've updated the logic to check on every change and revert back to the default when validation fails.

btxtiger commented 6 years ago

Looks good for me. I've nothing to add.