Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: siteLogin Arguments: site,username,pw,errCmd,succCmd Description: Login to a site. Return an error string, or "" if successful. Page type: webl Render function: Module: siteutil Page source: var err = "ERR_LOGIN_FAIL"; if (username != nil) and (username != "") and (pw != nil) and (pw != "") then pw = Base64_Encode(username + ":" + pw); var db = Wub_GetDB(site); var coll = Wub_GetCollection(db, "login"); var dbobj = Wub_NewDBObject([. pw=pw .]); var res = Wub_QueryDB(coll, dbobj, 20); if (Size(res) == 1) then var key = Base64_Encode(ToString(Wub_RandomInt(999999999999999))); coll = Wub_GetCollection(db, "session"); var data = res[0]; DeleteField(data, "pw"); dbobj = Wub_NewDBObject([. key=key, data=data .]); Wub_InsertDB(coll, dbobj); WubCall(succCmd, [key]); key else err = "ERR_AUTHENTICATION_ERROR"; WubCall(errCmd, [err]); err end; else err = "ERR_EMPTY_LOGIN"; WubCall(errCmd, [err]); err end;