mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge branch 'passwordStrength'
This commit is contained in:
commit
a1e24eb064
4 changed files with 66 additions and 0 deletions
|
@ -165,6 +165,17 @@ module.exports =
|
|||
{name: "French", code: "fr"}
|
||||
]
|
||||
|
||||
|
||||
# Password Settings
|
||||
# -----------
|
||||
# These restrict the passwords users can use when registering
|
||||
# opts are from http://antelle.github.io/passfield
|
||||
passwordStrengthOptions:
|
||||
pattern: "aA$3"
|
||||
length:
|
||||
min: 8
|
||||
max: 50
|
||||
|
||||
# Email support
|
||||
# -------------
|
||||
#
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
define [
|
||||
"base"
|
||||
"libs/passfield"
|
||||
], (App) ->
|
||||
App.directive "asyncForm", ($http) ->
|
||||
return {
|
||||
controller: ['$scope', ($scope) ->
|
||||
@getEmail = () ->
|
||||
return $scope.email
|
||||
return this
|
||||
]
|
||||
link: (scope, element, attrs) ->
|
||||
formName = attrs.asyncForm
|
||||
|
||||
|
@ -71,3 +77,49 @@ define [
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
App.directive 'complexPassword', ->
|
||||
require: ['^asyncForm', 'ngModel']
|
||||
|
||||
link: (scope, element, attrs, ctrl) ->
|
||||
|
||||
PassField.Config.blackList = []
|
||||
defaultPasswordOpts =
|
||||
pattern: ""
|
||||
length:
|
||||
min: 1
|
||||
max: 50
|
||||
allowEmpty: false
|
||||
allowAnyChars: false
|
||||
isMasked: true
|
||||
showToggle: false
|
||||
showGenerate: false
|
||||
showTip:false
|
||||
showWarn:false
|
||||
checkMode : PassField.CheckModes.STRICT
|
||||
chars:
|
||||
digits: "1234567890"
|
||||
letters: "abcdefghijklmnopqrstuvwxyz"
|
||||
letters_up: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
symbols: "@#$%^&*()-_=+[]{};:<>/?!£€.,"
|
||||
|
||||
opts = _.defaults(window.passwordStrengthOptions || {}, defaultPasswordOpts)
|
||||
if opts.length.min == 1
|
||||
opts.acceptRate = 0 #this allows basically anything to be a valid password
|
||||
passField = new PassField.Field("passwordFeild", opts);
|
||||
|
||||
[asyncFormCtrl, ngModelCtrl] = ctrl
|
||||
|
||||
ngModelCtrl.$parsers.unshift (modelValue) ->
|
||||
isValid = passField.validatePass()
|
||||
if !isValid
|
||||
scope.complexPasswordErrorMessage = passField.getPassValidationMessage()
|
||||
else
|
||||
email = asyncFormCtrl.getEmail()
|
||||
startOfEmail = email?.split("@")?[0]
|
||||
if modelValue.indexOf(email) != -1 or modelValue.indexOf(startOfEmail) != -1
|
||||
isValid = false
|
||||
scope.complexPasswordErrorMessage = "Password can not contain email address"
|
||||
ngModelCtrl.$setValidity('complexPassword', isValid)
|
||||
return modelValue
|
||||
|
|
|
@ -9,4 +9,5 @@ define [
|
|||
"libs/fineuploader"
|
||||
"libs/angular-sanitize-1.2.17"
|
||||
"libs/angular-cookie"
|
||||
"libs/passfield"
|
||||
], () ->
|
||||
|
|
2
services/web/public/js/libs/passfield.js
Normal file
2
services/web/public/js/libs/passfield.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue