diff options
-rwxr-xr-x | authtoken.json | 10 | ||||
-rw-r--r-- | index.html | 6 |
2 files changed, 10 insertions, 6 deletions
diff --git a/authtoken.json b/authtoken.json index 6d55799..a8cd31a 100755 --- a/authtoken.json +++ b/authtoken.json @@ -30,7 +30,7 @@ sub get_token my ($token) = $sth->fetchrow_array; return ('OK', 'success', $token) if(defined $token); - return ('ERROR', 'user "' . $username . '" not known', '') + return ('ERROR', "user '" . $username . "' not known", '') } my $status = 'ERROR'; @@ -47,8 +47,8 @@ if(defined $ENV{REMOTE_USER}) { print "Content-type: application/json\n\n"; print "{\n"; -print " 'status': '" . $status . "',\n"; -print " 'errorstring': '" . $errorstring . "',\n"; -print " 'username': '" . $username . "',\n"; -print " 'token': '" . $token . "'\n"; +print ' "status": "' . $status . '"'. ",\n"; +print ' "errorstring": "' . $errorstring . '"'. ",\n"; +print ' "username": "' . $username . '"' . ",\n"; +print ' "token": "' . $token . '"' . "\n"; print "}\n"; @@ -7,7 +7,11 @@ <script src="/javascript/jquery/jquery.min.js"></script> <script type="text/javascript"> function authSuccess(data) { - alert("username: " + data.username + "\ntoken: " + data.token ); + if (data.status == 'ERROR') { + alert("login error: " + data.errorstring); + } else { + alert("username: " + data.username + "\ntoken: " + data.token ); + } } function authError(req, status, error) { |