[OSM-dev] forum.openstreetmap.org

spaetz osm at sspaeth.de
Wed Oct 31 11:21:10 GMT 2007


On Wed, Oct 31, 2007 at 11:37:12AM +0100, Lambertus wrote:

> Well there is no such thing as 'install' a new auth method on the forum, 
> but I certainly can try to implement this.
> 
> Spaetz, can you post some relevant code snippets?

This is the whole authentication function (basically, I snipped a couple of irrelevant lines) as needed by the phorum plugin.

function phorum_mod_osmauth_userauth ($login) {
  // Input  : Array containing:
  //          username    => the username to check
  //          password    => the password to check
  //          user_id     => empty value
  // Return : Same as input

  $authURL=sprintf("http://%s:%s@api.openstreetmap.org/api/0.4/user/details",urlencode($login['username']),urlencode($login['password']));
  $header = get_headers($authURL,1);
  if ($header[0] == 'HTTP/1.0 200 OK') {
        // Does the user exist already?
        $login['user_id'] = phorum_api_user_search('username', $login[username]);
//      print "User: $login[username] id $login['user_id']";
        if (!$login['user_id']) {
                //Create the user
                $login['user_id'] = phorum_api_user_save (array("user_id" => NULL,
                        "username" => $login[username],
                        "real_name" => $login[username],
                        "email" => "ENTER ME!",
                        "active" => 1,
                        "password" => $login[password]));
        }
  }
  else
  {// remote auth failed. Fail totally (returning NULL would Phorum let do the auth locally)
    $login['user_id'] = FALSE;
  }
}




More information about the dev mailing list