Explorar el Código

token validity check

master
Robin Thoni hace 9 años
padre
commit
7da6f13162
Se han modificado 1 ficheros con 4 adiciones y 2 borrados
  1. 4
    2
      status.php

+ 4
- 2
status.php Ver fichero

@@ -5,9 +5,11 @@ require_once "misc/config.php";
5 5
 function check_token()
6 6
 {
7 7
   $token = check_table_field("Authorization", "tokens", "token");
8
-  if ($token === false)
8
+  $date = new DateTime($token["date"]);
9
+  $date->add(new DateInterval("P1D"));
10
+  if ($token === false || $date < new DateTime())
9 11
     error(401, "Invalid token");
10
-  return $token;
12
+  return $token['token'];
11 13
 }
12 14
 
13 15
 function status_confirm($id)

Loading…
Cancelar
Guardar