From: Zach Copley Date: Thu, 21 Oct 2010 00:28:28 +0000 (-0700) Subject: Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bfdb8385ecc745002b8c45510caf2fdf7c2d2c9f;p=quix0rs-gnu-social.git Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x Conflicts: actions/apioauthauthorize.php lib/apioauthstore.php --- bfdb8385ecc745002b8c45510caf2fdf7c2d2c9f diff --cc lib/apioauthstore.php index 9a26082633,76df6c1ed2..6b9b977560 --- a/lib/apioauthstore.php +++ b/lib/apioauthstore.php @@@ -37,36 -35,23 +37,38 @@@ class ApiStatusNetOAuthDataStore extend $con = new Consumer(); $con->consumer_key = $consumerKey; $con->consumer_secret = $consumerKey; + $con->created = common_sql_now(); + $result = $con->insert(); if (!$result) { - $this->serverError(_("Could not create anonymous consumer.")); + // TRANS: Server error displayed when trying to create an anynymous OAuth consumer. + $this->serverError(_('Could not create anonymous consumer.')); } - $app = new OAuth_application(); - $app->consumer_key = $con->consumer_key; - $app->name = 'anonymous'; - - // XXX: allow the user to set the access type when - // authorizing? Currently we default to r+w for anonymous - // OAuth client applications - $app->access_type = 3; // read + write - $id = $app->insert(); - if (!$id) { - // TRANS: Server error displayed when trying to create an anynymous OAuth application. - $this->serverError(_('Could not create anonymous OAuth application.')); + + $app = Oauth_application::getByConsumerKey('anonymous'); + + if (!$app) { + + common_debug("API OAuth - creating anonymous application"); + $app = new OAuth_application(); + $app->owner = 1; // XXX: What to do here? + $app->consumer_key = $con->consumer_key; + $app->name = 'anonymous'; + $app->icon = 'default-avatar-stream.png'; // XXX: Fix this! + $app->description = "An anonymous application"; + // XXX: allow the user to set the access type when + // authorizing? Currently we default to r+w for anonymous + // OAuth client applications + $app->access_type = 3; // read + write + $app->type = 2; // desktop + $app->created = common_sql_now(); + + $id = $app->insert(); + + if (!$id) { ++ // TRANS: Server error displayed when trying to create an anynymous OAuth application. + $this->serverError(_("Could not create anonymous OAuth application.")); + } } } else { return null;