mvp for password validation

This commit is contained in:
Henry Oswald 2015-04-24 14:33:01 +01:00
parent 7d109ce77d
commit 639f73ea74
3 changed files with 42 additions and 0 deletions

View file

@ -1,5 +1,6 @@
define [ define [
"base" "base"
"libs/passfield"
], (App) -> ], (App) ->
App.directive "asyncForm", ($http) -> App.directive "asyncForm", ($http) ->
return { return {
@ -71,3 +72,41 @@ define [
} }
} }
App.directive 'complexPassword', ->
require: ['^asyncForm', 'ngModel']
link: (scope, element, attrs, controllers) ->
passwordStrengthOptions = {
pattern: "aA$3",
allowEmpty: false,
allowAnyChars: false,
isMasked: true,
showToggle: false,
showGenerate: false,
checkMode:PassField.CheckModes.STRICT,
length: { min: 8, max: 50 },
showTip:false,
showWarn:false
}
passwordStrengthOptions.chars = {
digits: "1234567890",
letters: "abcdefghijklmnopqrstuvwxyz",
letters_up: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
symbols: "@#$%^&*()-_=+[]{};:<>/?!£€"
}
passField = new PassField.Field("passwordFeild", passwordStrengthOptions);
console.log controllers
controllers.$parsers.unshift (viewValue)->
console.log scope.parent, scope.password, attrs.email, viewValue
scope.complexPasswordErrorMessage = passField.getPassValidationMessage()
console.log scope.complexPasswordErrorMessage
isValid = passField.validatePass()
controllers.$setValidity('complexPassword', isValid)
return viewValue

View file

@ -9,4 +9,5 @@ define [
"libs/fineuploader" "libs/fineuploader"
"libs/angular-sanitize-1.2.17" "libs/angular-sanitize-1.2.17"
"libs/angular-cookie" "libs/angular-cookie"
"libs/passfield"
], () -> ], () ->

File diff suppressed because one or more lines are too long