Compare commits

...

2 Commits

Author SHA1 Message Date
Sascha Nitsch 073fba5312 renamed file to avoid name conflicts 2024-07-22 15:40:16 +02:00
Sascha Nitsch 47f82afcb5 fixed case of no longer existing user 2024-07-22 14:38:28 +02:00
3 changed files with 6 additions and 6 deletions

View File

@ -38,13 +38,13 @@ To configure an apache server, add the following rewrite rules:
<Directory /where/ever/you/put/it> <Directory /where/ever/you/put/it>
RewriteEngine on RewriteEngine on
RewriteBase / RewriteBase /
RewriteRule ^api/(.+)$ api.php?_call=$1 [L] RewriteRule ^api/federator/(.+)$ federator.php?_call=$1 [L]
RewriteRule ^(\.well-known/.*)$ /api.php?_call=$1 [L,END] RewriteRule ^(\.well-known/.*)$ /federator.php?_call=$1 [L,END]
</Directory> </Directory>
With the dummy plugin and everything installed correctly a With the dummy plugin and everything installed correctly a
> curl -v http://localhost/api/v1/dummy/moo -H "X-Session: somethingvalid" -H "X-Profile: ihaveone" > curl -v http://localhost/api/federator/v1/dummy/moo -H "X-Session: somethingvalid" -H "X-Profile: ihaveone"
should return a piece of ascii art. should return a piece of ascii art.

View File

@ -32,7 +32,8 @@ class User
openssl_pkey_export($private_key, $private); openssl_pkey_export($private_key, $private);
try { try {
$sql = 'insert into users (id, externalid, rsapublic, rsaprivate, validuntil)'; $sql = 'insert into users (id, externalid, rsapublic, rsaprivate, validuntil)';
$sql .= ' values (?, ?, ?, ?, now() + interval 1 day) on duplicate key update validuntil=now() + interval 1 day'; $sql .= ' values (?, ?, ?, ?, now() + interval 1 day)';
$sql .= ' on duplicate key update validuntil=now() + interval 1 day';
$stmt = $dbh->prepare($sql); $stmt = $dbh->prepare($sql);
if ($stmt === false) { if ($stmt === false) {
throw new \Federator\Exceptions\ServerError(); throw new \Federator\Exceptions\ServerError();
@ -119,8 +120,7 @@ class User
} }
} }
if ($cache !== null) { if ($cache !== null) {
print_r($user); if ($user->id === null && $user->externalid !== null) {
if ($user->id === null) {
self::addLocalUser($dbh, $user, $_name); self::addLocalUser($dbh, $user, $_name);
} }
$cache->saveRemoteUserByName($_name, $user); $cache->saveRemoteUserByName($_name, $user);