Commit d195737a authored by Marcel Rieger's avatar Marcel Rieger
Browse files

Reimplement minimum password length.

parent 6b701c40
......@@ -22,7 +22,7 @@ class User(Base):
INACTIVE = 0
ACTIVE = 1
MAX_USERS = 500
PW_LENGTH = [8, 64]
MIN_PW_LENGTH = 8
NAME_LENGTH = [6, 30]
NAME_CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_-+'
FORBIDDEN_NAMES = ['data', 'guest', 'global', 'user', 'delete',
......@@ -162,7 +162,10 @@ class User(Base):
def set_password(db, hash, password):
user = db.query(User).filter_by(hash=hash).first()
if not isinstance(user, User):
raise MessageException("Invalid hash")
raise MessageException("Invalid hash!")
if len(password) < User.MIN_PW_LENGTH:
raise MessageException("Please select a password with a minimum "
"length of %s!" % User.MIN_PW_LENGTH)
user.hash = None
user.password = sha256_crypt.encrypt(password)
if user.status == User.INACTIVE:
......
......@@ -47,7 +47,11 @@ var Vispa = Class.extend({
}
if (pass1 != pass2) {
Dialog.alert("Your passwords don't match!");
Dialog.alert("Your passwords don't match!", {
onClose: function() {
$("#password2").focus();
}
});
return this;
}
......@@ -58,7 +62,11 @@ var Vispa = Class.extend({
$.cookie("tmpPass", pass1, { expires: d });
window.location.href = self.url.dynamic("/");
}).fail(function(response, status, message) {
Dialog.alert(response.responseText || message);
Dialog.alert(response.responseText || message, {
onClose: function() {
$("#password1").focus();
}
});
});
return this;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment