Exception handling regarding Foreign_link

This commit is contained in:
Mikael Nordfeldth
2015-07-18 11:39:34 +02:00
parent b609a3610f
commit e0084a6fdf
12 changed files with 88 additions and 102 deletions

View File

@@ -62,12 +62,7 @@ if (have_option('n')) {
*/
function twitterAuthForUser(User $user)
{
$flink = Foreign_link::getByUserID($user->id,
TWITTER_SERVICE);
if (!$flink) {
throw new ServerException("No Twitter config for this user.");
}
$flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE);
$token = TwitterOAuthClient::unpackToken($flink->credentials);
if (!$token) {
throw new ServerException("No Twitter OAuth credentials for this user.");

View File

@@ -63,12 +63,7 @@ if (have_option('n')) {
*/
function twitterAuthForUser(User $user)
{
$flink = Foreign_link::getByUserID($user->id,
TWITTER_SERVICE);
if (!$flink) {
throw new ServerException("No Twitter config for this user.");
}
$flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE);
$token = TwitterOAuthClient::unpackToken($flink->credentials);
if (!$token) {
throw new ServerException("No Twitter OAuth credentials for this user.");