@@ -4,6 +4,6 @@ |
||
| 4 | 4 | include_once '../../_config/core.php'; |
| 5 | 5 | |
| 6 | 6 | $jwt = ""; |
| 7 | -if(setAuth($jwt, time()-3600)){ |
|
| 7 | +if (setAuth($jwt, time() - 3600)) { |
|
| 8 | 8 | returnSuccess(); |
| 9 | 9 | } |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | 45 | $jwt = JWT::encode($token, $token_conf['secret']); |
| 46 | - if(setAuth($jwt, $token_conf['expireDefault'])){ |
|
| 46 | + if (setAuth($jwt, $token_conf['expireDefault'])) { |
|
| 47 | 47 | returnSuccess(); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | 59 | $jwt = JWT::encode($token, $token_conf['secret']); |
| 60 | - if(setAuth($jwt, $token_conf['expireDefault'])){ |
|
| 60 | + if (setAuth($jwt, $token_conf['expireDefault'])) { |
|
| 61 | 61 | returnSuccess(); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -14,19 +14,19 @@ discard block |
||
| 14 | 14 | "expireDefault" => time() + (604800), |
| 15 | 15 | ); |
| 16 | 16 | |
| 17 | -function setAuth($token, $expire){ |
|
| 17 | +function setAuth($token, $expire) { |
|
| 18 | 18 | |
| 19 | 19 | //$domain = "localhost"; |
| 20 | 20 | $domain = ".eliareutlinger.ch"; |
| 21 | 21 | $secure = false; |
| 22 | - if(isset($_SERVER['HTTPS'])){ |
|
| 22 | + if (isset($_SERVER['HTTPS'])) { |
|
| 23 | 23 | $secure = true; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - $appCookie = setcookie ("appToken", $token, $expire, "/", $domain, $secure, false); |
|
| 27 | - $secureCookie = setcookie ("secureToken", $token, $expire, "/", $domain, $secure, true); |
|
| 26 | + $appCookie = setcookie("appToken", $token, $expire, "/", $domain, $secure, false); |
|
| 27 | + $secureCookie = setcookie("secureToken", $token, $expire, "/", $domain, $secure, true); |
|
| 28 | 28 | |
| 29 | - if($appCookie && $secureCookie){ |
|
| 29 | + if ($appCookie && $secureCookie) { |
|
| 30 | 30 | return true; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | list($type, $data) = explode(" ", getallheaders()['Authorization'], 2); |
| 41 | 41 | if (strcasecmp($type, "Bearer") == 0) { |
| 42 | 42 | |
| 43 | - if($_COOKIE["appToken"] === $data){ |
|
| 43 | + if ($_COOKIE["appToken"] === $data) { |
|
| 44 | 44 | return $_COOKIE["appToken"]; |
| 45 | 45 | } else { |
| 46 | 46 | returnForbidden("Tokens not correct"); |