Skip to content

Commit

Permalink
Enable callback
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoerlitz committed Jun 26, 2024
1 parent a70af56 commit 871cbab
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 11 deletions.
11 changes: 7 additions & 4 deletions VATGER/Auth/Pub/Controller/ConnectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function actionCallback()
// Find the first available username
$count = 1;
$fullDBName = $fullName;
while (\XF::finder('XF:User')->where('username', $fullDBName)->total() > 0) {
while (\XF::finder('XF:User')->where('username', $fullDBName)->fetch()->count() > 0) {
$fullDBName = $fullName . ' ' . $count;
$count++;
}
Expand Down Expand Up @@ -95,13 +95,16 @@ public function actionCallback()
try {
\XF::app()->http()->client()->post($this->options()['homepage_callback'], [
'json' => [
'cid' => $cid,
'vatsim_id' => $cid,
'forum_id' => $baseUser['user_id']
],
'headers' => [
'Authorization' => 'Token ' . $this->options()['homepage_token']
]
]);
} catch (\Exception $exception) {
// $baseUser->delete();
// return $this->error(self::$GENERIC_ERROR_MESSAGE, $exception->getMessage());
$baseUser->delete();
return $this->error(self::$GENERIC_ERROR_MESSAGE, $exception->getMessage());
}
}

Expand Down
4 changes: 4 additions & 0 deletions VATGER/Auth/_data/options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<default_value></default_value>
<relation group_id="vatgerAuth" display_order="3"/>
</option>
<option option_id="homepage_token" edit_format="textbox" data_type="string" advanced="0">
<default_value></default_value>
<relation group_id="vatgerAuth" display_order="3"/>
</option>
<option option_id="oauth_access_token_endpoint" edit_format="textbox" data_type="string" advanced="0">
<default_value>https://auth-dev.vatsim.net/oauth/token</default_value>
<relation group_id="vatgerAuth" display_order="1"/>
Expand Down
2 changes: 2 additions & 0 deletions VATGER/Auth/_data/phrases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<phrase title="option.email_mapping" version_id="1" version_string="0.0.1"><![CDATA[E-Mail Mapping]]></phrase>
<phrase title="option.full_name_mapping" version_id="1" version_string="0.0.1"><![CDATA[Full Name Mapping]]></phrase>
<phrase title="option.homepage_callback" version_id="1" version_string="0.0.1"><![CDATA[Homepage Callback URL]]></phrase>
<phrase title="option.homepage_token" version_id="5" version_string="0.0.5"><![CDATA[Homepage Token]]></phrase>
<phrase title="option.oauth_access_token_endpoint" version_id="2" version_string="0.0.2"><![CDATA[Access Token Endpoint]]></phrase>
<phrase title="option.oauth_auth_endpoint" version_id="2" version_string="0.0.2"><![CDATA[Auth Endpoint]]></phrase>
<phrase title="option.oauth_user_endpoint" version_id="2" version_string="0.0.2"><![CDATA[User Information Endpoint]]></phrase>
Expand All @@ -32,6 +33,7 @@ If we wanted to access the cid, we would use the string: <strong>data.cid</stron
<phrase title="option_explain.email_mapping" version_id="1" version_string="0.0.1"><![CDATA[If we wanted to access the email, we would use the string: <strong>data.personal.email</strong>.]]></phrase>
<phrase title="option_explain.full_name_mapping" version_id="1" version_string="0.0.1"><![CDATA[If we wanted to access the full name, we would use the string: <strong>data.personal.full_name</strong>.]]></phrase>
<phrase title="option_explain.homepage_callback" version_id="1" version_string="0.0.1"><![CDATA[The homepage callback URL is used to notify the homepage of a new client being created. It sends a post request to the specified endpoint containing the CID and Board (Forum) ID of the user in question.]]></phrase>
<phrase title="option_explain.homepage_token" version_id="5" version_string="0.0.5"><![CDATA[The token used for the post request to the callback method.]]></phrase>
<phrase title="option_explain.oauth_access_token_endpoint" version_id="2" version_string="0.0.2"><![CDATA[This is the endpoint from which tokens are requested (POST).]]></phrase>
<phrase title="option_explain.oauth_auth_endpoint" version_id="2" version_string="0.0.2"><![CDATA[This is the endpoint to which the user will be redirected.]]></phrase>
<phrase title="option_explain.oauth_user_endpoint" version_id="2" version_string="0.0.2"><![CDATA[This is the endpoint from which the user information will be queried.]]></phrase>
Expand Down
4 changes: 2 additions & 2 deletions VATGER/Auth/_data/templates.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<templates>
<template type="public" title="PAGE_CONTAINER" version_id="1" version_string="0.0.1"><![CDATA[<!DOCTYPE html>
<template type="public" title="PAGE_CONTAINER" version_id="5" version_string="0.0.5"><![CDATA[<!DOCTYPE html>
<html id="XF" lang="{$xf.language.language_code}" dir="{$xf.language.text_direction}"
data-app="public"
data-template="{$template}"
Expand Down Expand Up @@ -81,7 +81,7 @@
</a>
</xf:if>
<xf:if is="$xf.visitor.is_moderator && $xf.session.using_functional_account">
<xf:if is="$xf.session.using_functional_account">
<a href="/functional/leave" class="p-staffBar-link">
Funktionsaccount Verlassen
</a>
Expand Down
3 changes: 3 additions & 0 deletions VATGER/Auth/_output/options/_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"homepage_callback.json": {
"hash": "68c85cae57edc5a9c20d8a605fb93cb6"
},
"homepage_token.json": {
"hash": "68c85cae57edc5a9c20d8a605fb93cb6"
},
"oauth_access_token_endpoint.json": {
"hash": "a3ccddcd9dbd59de01e81a14f42cc75e"
},
Expand Down
12 changes: 12 additions & 0 deletions VATGER/Auth/_output/phrases/_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
"version_string": "0.0.1",
"hash": "61f025c6b6d7f25ce22fd9de55e40793"
},
"option.homepage_token.txt": {
"global_cache": false,
"version_id": 5,
"version_string": "0.0.5",
"hash": "4d93534188d0e5b4fb36bea18b9ddf35"
},
"option.oauth_access_token_endpoint.txt": {
"global_cache": false,
"version_id": 2,
Expand Down Expand Up @@ -101,6 +107,12 @@
"version_string": "0.0.1",
"hash": "be8e814efb63dfcdc90c17a4a0a28eec"
},
"option_explain.homepage_token.txt": {
"global_cache": false,
"version_id": 5,
"version_string": "0.0.5",
"hash": "27a365c1d8d672b607c018b1772bbf9e"
},
"option_explain.oauth_access_token_endpoint.txt": {
"global_cache": false,
"version_id": 2,
Expand Down
6 changes: 3 additions & 3 deletions VATGER/Auth/_output/templates/_metadata.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"public/PAGE_CONTAINER.html": {
"version_id": 1,
"version_string": "0.0.1",
"hash": "ec0c95336bddee22e31189354dbd2050"
"version_id": 5,
"version_string": "0.0.5",
"hash": "1443d0d904c8b8f0856415b4b349df25"
},
"public/select_functional_account.html": {
"version_id": 1,
Expand Down
4 changes: 2 additions & 2 deletions VATGER/Auth/addon.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"legacy_addon_id": "",
"title": "VATSIM Germany Authentication",
"description": "The VATSIM Germany Auth plugin integrates with VATGER's OAuth2 implementation to allow SSO login in Xenforo.",
"version_id": 5,
"version_string": "0.0.5",
"version_id": 10,
"version_string": "1.0.0",
"dev": "VATSIM Germany",
"dev_url": "https://vatsim-germany.org",
"faq_url": "",
Expand Down

0 comments on commit 871cbab

Please sign in to comment.