diff options
author | ausiv4 <ausiv4@eb105b4a-77de-11de-a249-6bf219df57d5> | 2009-07-25 15:33:37 +0000 |
---|---|---|
committer | ausiv4 <ausiv4@eb105b4a-77de-11de-a249-6bf219df57d5> | 2009-07-25 15:33:37 +0000 |
commit | ebfe7e1cfc90e392112b831a1999ec8569b0354f (patch) | |
tree | b2c8acc6328b0d8ea2e40f2b2bebd6ca5e0a1113 /django/srpproject | |
parent | 24bea39a0932c2123ead106ab7b72e871ace8e25 (diff) |
This commit makes major revisions to srp.js. The SRP library now works
as a class. It is instantiated by:
var srp = new SRP(username, password, server_type, base_url);
Then it is run by calling:
srp.register()
to register a new user, and
srp.identify()
to authenticate an existing user. By default, a successful
identification pops up an alert reading "Authentication Successful."
To change this, set srp.success to a function. For example,
srp.success = function()
{
alert("We win!");
}
The same is true for error messages. By default, the SRP library sends
the message to the user as an alert box, but web designers can replace
the srp.error_message function to handle the error messages differently.
The most significant part of making the SRP library into a class is that
it cleans up the namespace. Instead of having tons of srp_Variables, we
only add the SRP() function to the namespace, and all other variables
are either private, public, or protected members of that class.
A few minor edits were made to views.py to support logging in with the
modified library. I haven't made the modifications to register yet, so
it won't work for this revision. Oops.
Diffstat (limited to 'django/srpproject')
-rw-r--r-- | django/srpproject/srp/views.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/django/srpproject/srp/views.py b/django/srpproject/srp/views.py index 834bce0..7df7ee6 100644 --- a/django/srpproject/srp/views.py +++ b/django/srpproject/srp/views.py @@ -36,14 +36,23 @@ def login_page(request): <script src="http://%s/srp-test/javascript/jsbn2.js"></script> <script src="http://%s/srp-test/javascript/srp.js"></script> <script type="text/javascript"> - function srp_success() + function login() + { + var username = document.getElementById("srp_username").value; + var password = document.getElementById("srp_password").value; + var url = window.location.protocol+"//"+window.location.host+"/srp/"; + srp = new SRP(username, password, "django", url); + srp.success = function() { - alert("Authentication successful."); - } + alert("We win"); + }; + srp.identify(); + return false; + } </script> </head> <body> - <form action="." onsubmit="return srp_identify()"> + <form action="." onsubmit="return login()"> <table> <tr><td>Username:</td><td><input type="text" id="srp_username" /></td></tr> <tr><td>Password:</td><td><input type="password" id="srp_password" /></td></tr> |