Monday, November 08, 2010 at 12:01 AM.


on authenticate (username, password, server="") {
		<<3/12/09; 6:05:58 AM by DW
			<<New optional param, server, allows you to post to another instance of Laconica.
		<<7/19/08; 11:08:21 AM by DW
			<<Add a cache.
		<<7/19/08; 10:57:49 AM by DW
			<<Created. Returns true if the user has a valid login false otherwise.
	local (adrcache);
	bundle { //check the cache
		adrcache = @system.temp.identicaAuthentications;
		if not defined (adrcache^) {
			new (tabletype, adrcache)};
		adrcache = @adrcache^.[server];
		if not defined (adrcache^) {
			new (tabletype, adrcache)};
		adrcache = @adrcache^.[username];
		if defined (adrcache^) {
			if adrcache^ == password {
				return (true)}}};
	try {
		local (replies);
		if identica.getReplies (@replies, username, password, server) {
			adrcache^ = password;
			return (true)}};
	return (false)}
<<bundle //test code
	<<dialog.alert (authenticate ("georgematesky", "fuckyou!"))
	<<dialog.alert (authenticate (user.identica.prefs.username, user.identica.prefs.password, ""))
	<<dialog.alert (authenticate (user.identica.prefs.username, user.identica.prefs.password))

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.