Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mevdschee committed Nov 30, 2022
1 parent d8e7479 commit 75cefde
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
31 changes: 29 additions & 2 deletions api.include.php
Expand Up @@ -8084,6 +8084,15 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
if ($sessionName) {
session_name($sessionName);
}
if (!ini_get('session.cookie_samesite')) {
ini_set('session.cookie_samesite', 'Lax');
}
if (!ini_get('session.cookie_httponly')) {
ini_set('session.cookie_httponly', 1);
}
if (!ini_get('session.cookie_secure') && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
ini_set('session.cookie_secure', 1);
}
session_start();
}
}
Expand Down Expand Up @@ -8296,6 +8305,15 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
if ($sessionName) {
session_name($sessionName);
}
if (!ini_get('session.cookie_samesite')) {
ini_set('session.cookie_samesite', 'Lax');
}
if (!ini_get('session.cookie_httponly')) {
ini_set('session.cookie_httponly', 1);
}
if (!ini_get('session.cookie_secure') && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
ini_set('session.cookie_secure', 1);
}
session_start();
}
}
Expand Down Expand Up @@ -8335,7 +8353,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
if (!$registerUser) {
return $this->responder->error(ErrorCode::AUTHENTICATION_FAILED, $username);
}
if(strlen(trim($username)) == 0){
if (strlen(trim($username)) == 0) {
return $this->responder->error(ErrorCode::USERNAME_EMPTY, $username);
}
if (strlen($password) < $passwordLength) {
Expand All @@ -8352,7 +8370,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$this->db->createSingle($table, $data);
$users = $this->db->selectAll($table, $columnNames, $condition, $columnOrdering, 0, 1);
foreach ($users as $user) {
if($loginAfterRegistration){
if ($loginAfterRegistration) {
if (!headers_sent()) {
session_regenerate_id(true);
}
Expand Down Expand Up @@ -8884,6 +8902,15 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
if ($sessionName) {
session_name($sessionName);
}
if (!ini_get('session.cookie_samesite')) {
ini_set('session.cookie_samesite', 'Lax');
}
if (!ini_get('session.cookie_httponly')) {
ini_set('session.cookie_httponly', 1);
}
if (!ini_get('session.cookie_secure') && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
ini_set('session.cookie_secure', 1);
}
session_start();
}
}
Expand Down
31 changes: 29 additions & 2 deletions api.php
Expand Up @@ -8084,6 +8084,15 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
if ($sessionName) {
session_name($sessionName);
}
if (!ini_get('session.cookie_samesite')) {
ini_set('session.cookie_samesite', 'Lax');
}
if (!ini_get('session.cookie_httponly')) {
ini_set('session.cookie_httponly', 1);
}
if (!ini_get('session.cookie_secure') && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
ini_set('session.cookie_secure', 1);
}
session_start();
}
}
Expand Down Expand Up @@ -8296,6 +8305,15 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
if ($sessionName) {
session_name($sessionName);
}
if (!ini_get('session.cookie_samesite')) {
ini_set('session.cookie_samesite', 'Lax');
}
if (!ini_get('session.cookie_httponly')) {
ini_set('session.cookie_httponly', 1);
}
if (!ini_get('session.cookie_secure') && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
ini_set('session.cookie_secure', 1);
}
session_start();
}
}
Expand Down Expand Up @@ -8335,7 +8353,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
if (!$registerUser) {
return $this->responder->error(ErrorCode::AUTHENTICATION_FAILED, $username);
}
if(strlen(trim($username)) == 0){
if (strlen(trim($username)) == 0) {
return $this->responder->error(ErrorCode::USERNAME_EMPTY, $username);
}
if (strlen($password) < $passwordLength) {
Expand All @@ -8352,7 +8370,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$this->db->createSingle($table, $data);
$users = $this->db->selectAll($table, $columnNames, $condition, $columnOrdering, 0, 1);
foreach ($users as $user) {
if($loginAfterRegistration){
if ($loginAfterRegistration) {
if (!headers_sent()) {
session_regenerate_id(true);
}
Expand Down Expand Up @@ -8884,6 +8902,15 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
if ($sessionName) {
session_name($sessionName);
}
if (!ini_get('session.cookie_samesite')) {
ini_set('session.cookie_samesite', 'Lax');
}
if (!ini_get('session.cookie_httponly')) {
ini_set('session.cookie_httponly', 1);
}
if (!ini_get('session.cookie_secure') && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
ini_set('session.cookie_secure', 1);
}
session_start();
}
}
Expand Down

0 comments on commit 75cefde

Please sign in to comment.