Monday, April 04, 2011 at 1:07 AM.

radio2Suite.validateApiCall

on validateApiCall (adradruser) {
	<<Changes
		<<3/14/11; 12:18:01 AM by DW
			<<Respect new adrdata^.prefs.apiEnabled boolean.
		<<3/13/11; 5:23:53 PM by DW
			<<Created. 
	local (pta = html.getpagetableaddress (), adrdata = radio2suite.init ());
	if not adrdata^.prefs.apiEnabled { //3/14/11 by DW
		scripterror ("Can't access the site because the API is not enabled.")};
	if webserver.util.parseAuth (pta) { //get username and password
		local (adruser = @adrdata^.users.[pta^.username]);
		if not defined (adruser^) {
			scripterror ("Can't access the site because there is no user named \"" + pta^.username + ".\"")};
		if not adruser^.prefs.enabled { //3/5/11 by DW
			scripterror ("Can't access the site because it is being worked on at this time.")};
		if opmlEditor.member.validate (pta^.username, string (pta^.password)) {
			adradruser^ = adruser;
			radio2suite.inituser (adruser); //2/21/11 by DW
			return (true)}};
	bundle { //send challenge
		local (pagebody = "A valid username and password are required to access this page.");
		pta^.responseBody = webserver.util.buildErrorPage ("401 Unauthorized", pagebody);
		pta^.responseHeaders.["WWW-Authenticate"] = "Basic realm=\"" + radio2Info.name + "\"";
		pta^.code = 401;
		return (false)}}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.