添加了登陆,修改密码,注册三个页面的csrf;

添加了usernameCheck的valuedation检测方法;
urls.py 添加了register,change_password页面。
This commit is contained in:
sxw
2015-08-04 16:05:40 +08:00
parent 68c5a580d7
commit 62a9e050f5
8 changed files with 75 additions and 5 deletions

View File

@@ -0,0 +1,44 @@
/**
* usernameCheck validator
*/
(function(root, factory) {
"use strict";
// AMD module is defined
if (typeof define === "function" && define.amd) {
define("validator/usernameCheck", ["jquery", "base", "csrf"], factory);
} else {
// planted over the root!
factory(root.jQuery, root.FormValidation);
}
}(this, function ($, FormValidation, csrfHeader) {
FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
'en_US': {
usernameCheck: {
'default': 'Please input the same value'
}
}
});
FormValidation.Validator.usernameCheck = {
validate: function(validator, $field, options) {
if ($field.val() == '')
return true;
return !$.ajax({
async: false,
beforeSend: csrfHeader,
url: "/api/username_check/",
data: {username: $field.val()},
dataType: "json",
method: "post",
}).responseJSON.data;
}
};
}));