summaryrefslogtreecommitdiffstats
path: root/web/lib/aur.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2017-04-27 09:24:11 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2017-04-30 16:47:13 +0200
commita8ac2004d3f25877d9e7b4fa58f10009c39f8acf (patch)
tree968cb95c2e7617608f15ccece4823ea4006c59cf /web/lib/aur.inc.php
parent6892ec7791bf04361ac2973b38d0025b50fa4727 (diff)
downloadaur-a8ac2004d3f25877d9e7b4fa58f10009c39f8acf.tar.gz
aur-a8ac2004d3f25877d9e7b4fa58f10009c39f8acf.tar.xz
Add support for Terms of Service documents
This allows for adding Terms of Service documents to the database that registered users need to accept before using the AUR. A revision field can be used to indicate whether a document was updated. If it is increased, all users are again asked to accept the new terms. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/lib/aur.inc.php')
-rw-r--r--web/lib/aur.inc.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php
index 063de8fc..ce569ea7 100644
--- a/web/lib/aur.inc.php
+++ b/web/lib/aur.inc.php
@@ -22,6 +22,7 @@ include_once('timezone.inc.php');
set_tz();
check_sid();
+check_tos();
/**
* Check if a visitor is logged in
@@ -92,6 +93,28 @@ function check_sid() {
}
/**
+ * Redirect user to the Terms of Service agreement if there are updated terms.
+ *
+ * @return void
+ */
+function check_tos() {
+ if (!isset($_COOKIE["AURSID"])) {
+ return;
+ }
+
+ $path = $_SERVER['PATH_INFO'];
+ $route = get_route($path);
+ if (!$route || $route == "tos.php") {
+ return;
+ }
+
+ if (count(fetch_updated_terms(uid_from_sid($_COOKIE["AURSID"]))) > 0) {
+ header('Location: ' . get_uri('/tos'));
+ exit();
+ }
+}
+
+/**
* Verify the supplied CSRF token matches expected token
*
* @return bool True if the CSRF token is the same as the cookie SID, otherwise false