Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | minor cleanups to how FossilAjaj stores its auth info. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | json-multitag-test | json |
| Files: | files | file ages | folders |
| SHA1: |
fb55f2534d097615afc13bea97fb8377 |
| User & Date: | stephan 2011-10-09 11:09:31.610 |
Context
|
2011-10-09
| ||
| 11:23 | Added /json/g, which dumps the "g" object to JSON (debuggering tool). check-in: 65e0c94c8a user: stephan tags: json-multitag-test, json | |
| 11:09 | minor cleanups to how FossilAjaj stores its auth info. check-in: fb55f2534d user: stephan tags: json-multitag-test, json | |
| 11:04 | minor pedantic mtime "as int" casts. check-in: 770f9da54a user: stephan tags: json-multitag-test, json | |
Changes
Changes to ajax/i-test/rhino-test.js.
| ︙ | ︙ | |||
135 136 137 138 139 140 141 |
assert( 'string' === typeof TestApp.fossil.auth.name, 'User name = '+TestApp.fossil.auth.name);
}
testAnonymousLogin.description = 'Perform anonymous login.';
function testAnonWiki(){
TestApp.fossil.sendCommand('/json/wiki/list',undefined,{
beforeSend:function(req,opt){
| | | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
assert( 'string' === typeof TestApp.fossil.auth.name, 'User name = '+TestApp.fossil.auth.name);
}
testAnonymousLogin.description = 'Perform anonymous login.';
function testAnonWiki(){
TestApp.fossil.sendCommand('/json/wiki/list',undefined,{
beforeSend:function(req,opt){
assert( req && (req.authToken==TestApp.fossil.auth.authToken), 'Request envelope contains expected authToken.' );
},
onResponse:function(resp,req){
assertResponseOK(resp);
assert( (typeof [] === typeof resp.payload) && resp.payload.length,
"Wiki list seems to be okay.");
TestApp.wiki.list = resp.payload;
}
|
| ︙ | ︙ |
Changes to ajax/js/fossil-ajaj.js.
| ︙ | ︙ | |||
38 39 40 41 42 43 44 |
/**
Sends a command to the fossil back-end. Command should be the
path part of the URL, e.g. /json/stat, payload is a request-specific
value type (may often be null/undefined). ajajOpt is an optional object
holding WhAjaj.sendRequest()-compatible options.
This function constructs a Fossil/JSON request envelope based
| | | | | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
/**
Sends a command to the fossil back-end. Command should be the
path part of the URL, e.g. /json/stat, payload is a request-specific
value type (may often be null/undefined). ajajOpt is an optional object
holding WhAjaj.sendRequest()-compatible options.
This function constructs a Fossil/JSON request envelope based
on the given arguments and adds this.auth.authToken and a requestId
to it.
*/
FossilAjaj.prototype.sendCommand = function(command, payload, ajajOpt) {
var req;
ajajOpt = ajajOpt || {};
if(payload || (this.auth && this.auth.authToken) || ajajOpt.jsonp) {
req = {
payload:payload,
requestId:('function' === typeof this.generateRequestId) ? this.generateRequestId() : undefined,
authToken:(this.auth ? this.auth.authToken : undefined),
jsonp:('string' === typeof ajajOpt.jsonp) ? ajajOpt.jsonp : undefined
};
}
ajajOpt.method = req ? 'POST' : 'GET';
// just for debuggering: ajajOpt.method = 'POST'; if(!req) req={};
if(command) ajajOpt.url = this.ajaj.derivedOption('url',ajajOpt) + command;
this.ajaj.sendRequest(req,ajajOpt);
};
/**
Sends a login request to the back-end.
ajajOpt is an optional configuration object suitable for passing
to sendCommand().
After the response returns, this.auth will be
set to the response payload.
If name === 'anonymous' (the default if none is passed in) then this
function ignores the pw argument and must make two requests - the first
one gets the captcha code and the second one submits it.
ajajOpt.onResponse() (if set) is only called for the actual login
response (the 2nd one), as opposed to being called for both requests.
|
| ︙ | ︙ | |||
93 94 95 96 97 98 99 |
};
ajajOpt = this.ajaj.normalizeAjaxParameters( ajajOpt || {} );
var oldOnResponse = ajajOpt.onResponse;
ajajOpt.onResponse = function(resp,req) {
var thisOpt = this;
//alert('login response:\n'+WhAjaj.stringify(resp));
if( resp && resp.payload ) {
| < | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
};
ajajOpt = this.ajaj.normalizeAjaxParameters( ajajOpt || {} );
var oldOnResponse = ajajOpt.onResponse;
ajajOpt.onResponse = function(resp,req) {
var thisOpt = this;
//alert('login response:\n'+WhAjaj.stringify(resp));
if( resp && resp.payload ) {
//self.userName = resp.payload.name;
//self.capabilities = resp.payload.capabilities;
self.auth = resp.payload;
}
if( WhAjaj.isFunction( self.onLogin ) ){
try{ self.onLogin(); }
catch(e){}
|
| ︙ | ︙ | |||
138 139 140 141 142 143 144 |
Logs out of fossil, invaliding this login token.
ajajOpt is an optional configuration object suitable for passing
to sendCommand().
If this object has an onLogout() function it is called (with
no arguments) before the onResponse() handler is called.
| | < | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
Logs out of fossil, invaliding this login token.
ajajOpt is an optional configuration object suitable for passing
to sendCommand().
If this object has an onLogout() function it is called (with
no arguments) before the onResponse() handler is called.
IFF the response succeeds then this.auth is unset.
*/
FossilAjaj.prototype.logout = function(ajajOpt) {
var self = this;
ajajOpt = this.ajaj.normalizeAjaxParameters( ajajOpt || {} );
var oldOnResponse = ajajOpt.onResponse;
ajajOpt.onResponse = function(resp,req) {
var thisOpt = this;
if( resp && !resp.payload ){
delete self.auth;
}
if( WhAjaj.isFunction( self.onLogout ) ){
try{ self.onLogout(); }
catch(e){}
}
if( WhAjaj.isFunction(oldOnResponse) ) {
|
| ︙ | ︙ |