Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit ca32192

Browse files
committed
Adds linked_accounts to API response.
1 parent a1eb6de commit ca32192

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

Api/Controller/Linking.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function actionGet(ParameterBag $params)
4040

4141
$finder = \XF::finder('YogstationPermissions:LinkedAccount');
4242

43-
$linked_account = $finder->where('account_id', $params->account_type)
43+
$linked_account = $finder->where('account_id', $params->account_id)
4444
->where('account_type', $params->account_type)
4545
->with('User')->fetchOne();
4646

Setup.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function installStep1()
2424
$table->addColumn('user_id', 'int');
2525
$table->addColumn('account_type', 'varchar', 64);
2626
$table->addColumn('account_id', 'varchar', 255);
27-
$table->addPrimaryKey('user_id');
27+
$table->addPrimaryKey(['user_id', 'account_type']);
2828
});
2929

3030
$this->schemaManager()->createTable('yg_linking_key', function(\XF\Db\Schema\Create $table)
@@ -35,5 +35,12 @@ public function installStep1()
3535
$table->addColumn('expires', 'int');
3636
$table->addPrimaryKey('linking_key');
3737
});
38-
}
38+
}
39+
40+
public function uninstallStep1()
41+
{
42+
$this->schemaManager()->dropTable('yg_linked_account');
43+
$this->schemaManager()->dropTable('yg_linking_key');
44+
}
45+
3946
}

XF/Entity/User.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ protected function setupApiResultData(
3535
parent::setupApiResultData($result, $verbosity, $options);
3636

3737
$result->permissions = $this->getPermissions();
38-
$result->linked_accounts = $this->LinkedAccounts;
38+
39+
$linked_accounts = [];
40+
41+
foreach ($this->LinkedAccounts as $account)
42+
{
43+
$linked_accounts[$account->account_type] = $account->account_id;
44+
}
45+
46+
$result->linked_account = $linked_accounts;
3947
}
4048
}

addon.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"legacy_addon_id": "",
33
"title": "Yogstation Permissions",
44
"description": "",
5-
"version_id": 20201007,
6-
"version_string": "20201007",
5+
"version_id": 20201008,
6+
"version_string": "20201008",
77
"dev": "",
88
"dev_url": "",
99
"faq_url": "",

0 commit comments

Comments
 (0)