Skip to content

Commit 8be93a4

Browse files
committed
added login cookie ttl
1 parent d0ccf2a commit 8be93a4

File tree

10 files changed

+71
-2
lines changed

10 files changed

+71
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace VATGER\Auth\ControllerPlugin;
4+
5+
use XF\Repository\UserRememberRepository;
6+
7+
class LoginPlugin extends XFCP_LoginPlugin {
8+
public function createVisitorRememberKey(): void
9+
{
10+
$cookie_ttl = intval($this->options()->login_session_length ?? 31536000);
11+
12+
$visitor = \XF::visitor();
13+
if (!$visitor->user_id)
14+
{
15+
return;
16+
}
17+
18+
/** @var UserRememberRepository $rememberRepo */
19+
$rememberRepo = $this->repository(UserRememberRepository::class);
20+
$key = $rememberRepo->createRememberRecord($visitor->user_id);
21+
$value = $rememberRepo->getCookieValue($visitor->user_id, $key);
22+
23+
$this->app->response()->setCookie('user', $value, $cookie_ttl);
24+
}
25+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"from_class": "XF\\ControllerPlugin\\LoginPlugin",
3+
"to_class": "VATGER\\Auth\\ControllerPlugin\\LoginPlugin",
4+
"execute_order": 10,
5+
"active": true
6+
}

VATGER/Auth/_output/class_extensions/_metadata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"XF-ControllerPlugin-LoginPlugin_VATGER-Auth-ControllerPlugin-LoginPlugin.json": {
3+
"hash": "adc702faf9546a1f981e890bb654e93d"
4+
},
25
"XF-Entity-PermissionEntry_VATGER-Auth-Entity-PermissionEntry.json": {
36
"hash": "07ad974fac2f08a79ca409c88412c947"
47
},

VATGER/Auth/_output/extension_hint.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
// ################## THIS IS A GENERATED FILE ##################
55
// DO NOT EDIT DIRECTLY. EDIT THE CLASS EXTENSIONS IN THE CONTROL PANEL.
66

7+
namespace VATGER\Auth\ControllerPlugin
8+
{
9+
class XFCP_LoginPlugin extends \XF\ControllerPlugin\LoginPlugin {}
10+
}
11+
712
namespace VATGER\Auth\Entity
813
{
914
class XFCP_PermissionEntry extends \XF\Entity\PermissionEntry {}

VATGER/Auth/_output/options/_metadata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
"homepage_token.json": {
2121
"hash": "68c85cae57edc5a9c20d8a605fb93cb6"
2222
},
23+
"login_session_length.json": {
24+
"hash": "c86f730eddc5f3656c8725fd5a704171"
25+
},
2326
"oauth_access_token_endpoint.json": {
2427
"hash": "a3ccddcd9dbd59de01e81a14f42cc75e"
2528
},
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"edit_format": "spinbox",
3+
"edit_format_params": "",
4+
"data_type": "positive_integer",
5+
"sub_options": [],
6+
"validation_class": "",
7+
"validation_method": "",
8+
"advanced": false,
9+
"default_value": "31536000",
10+
"relations": {
11+
"vatgerAuth": 5
12+
}
13+
}

VATGER/Auth/_output/phrases/_metadata.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@
113113
"version_string": "0.0.5",
114114
"hash": "4d93534188d0e5b4fb36bea18b9ddf35"
115115
},
116+
"option.login_session_length.txt": {
117+
"global_cache": false,
118+
"version_id": 153,
119+
"version_string": "1.5.3",
120+
"hash": "0b3bfb6b903fcfaf6b2d7d643906c578"
121+
},
116122
"option.oauth_access_token_endpoint.txt": {
117123
"global_cache": false,
118124
"version_id": 2,
@@ -203,6 +209,12 @@
203209
"version_string": "0.0.5",
204210
"hash": "27a365c1d8d672b607c018b1772bbf9e"
205211
},
212+
"option_explain.login_session_length.txt": {
213+
"global_cache": false,
214+
"version_id": 153,
215+
"version_string": "1.5.3",
216+
"hash": "302097086834ec00b3316f67039d64fe"
217+
},
206218
"option_explain.oauth_access_token_endpoint.txt": {
207219
"global_cache": false,
208220
"version_id": 2,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
XF_User Cookie TTL
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Time in seconds after which the XF_User cookie will no longer be valid.

VATGER/Auth/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": "VATSIM Germany",
44
"description": "The VATSIM Germany plugin integrates with VATGER's OAuth2 implementation to allow SSO login in Xenforo.",
5-
"version_id": 152,
6-
"version_string": "1.5.2",
5+
"version_id": 153,
6+
"version_string": "1.5.3",
77
"dev": "VATSIM Germany",
88
"dev_url": "https://vatsim-germany.org",
99
"faq_url": "",

0 commit comments

Comments
 (0)