mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Remove console restrictions
This commit is contained in:
@@ -65,9 +65,9 @@ $utopia->post('/v1/auth/register')
|
||||
|
||||
if (!empty($profile)) {
|
||||
if ($failure) {
|
||||
//$response->redirect($failure);
|
||||
$response->redirect($failure . '?message=User already registered');
|
||||
|
||||
//return;
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Exception('User already registered', 400);
|
||||
@@ -331,9 +331,9 @@ $utopia->post('/v1/auth/login')
|
||||
;
|
||||
|
||||
if ($failure) {
|
||||
//$response->redirect($failure);
|
||||
$response->redirect($failure);
|
||||
|
||||
//return;
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Exception('Invalid credentials', 401); // Wrong password or username
|
||||
@@ -390,7 +390,7 @@ $utopia->delete('/v1/auth/logout')
|
||||
->label('scope', 'account')
|
||||
->label('sdk.namespace', 'auth')
|
||||
->label('sdk.method', 'logout')
|
||||
->label('sdk.description', 'Use this endpoint to log out the currently logged in user from his account. When succeed this endpoint will delete the user session and remove the session secret cookie.')
|
||||
->label('sdk.description', 'Use this endpoint to log out the currently logged in user from his account. When succeed this endpoint will delete the user session and remove the session secret cookie from the user client.')
|
||||
->label('abuse-limit', 100)
|
||||
->action(
|
||||
function () use ($response, $request, $user, $projectDB, $audit, $webhook) {
|
||||
|
||||
+1
-4
@@ -32,10 +32,7 @@ services:
|
||||
- _APP_INFLUXDB_PORT=8086
|
||||
- _APP_STATSD_HOST=telegraf
|
||||
- _APP_STATSD_PORT=8125
|
||||
#- _APP_CONSOLE_WHITELIST_EMAILS=user1@example.com,user2@example.com
|
||||
#- _APP_CONSOLE_WHITELIST_IPS=192.1.1.100,192.1.1.101
|
||||
#- _APP_CONSOLE_WHITELIST_DOMAINS=appwrite.io,example.com
|
||||
|
||||
|
||||
mariadb:
|
||||
image: appwrite/mariadb:1.0.0 # fix issues when upgrading using: mysql_upgrade -u root -p
|
||||
restart: unless-stopped
|
||||
|
||||
@@ -224,12 +224,29 @@ class Client
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
$responseHeaders['status-code'] = $responseStatus;
|
||||
|
||||
return [
|
||||
'headers' => $responseHeaders,
|
||||
'body' => $responseBody
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse Cookie String
|
||||
*
|
||||
* @param string $cookie
|
||||
* @return array
|
||||
*/
|
||||
public function parseCookie($cookie)
|
||||
{
|
||||
$cookies = [];
|
||||
|
||||
parse_str(strtr($cookie, array('&' => '%26', '+' => '%2B', ';' => '&')), $cookies);
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten params array to PHP multiple format
|
||||
*
|
||||
|
||||
@@ -70,9 +70,37 @@ class ConsoleTest extends TestCase
|
||||
'failure' => 'http://localhost/failure',
|
||||
]);
|
||||
|
||||
var_dump();
|
||||
$session = $this->client->parseCookie($response['headers']['set-cookie'])['a-session-console'];
|
||||
var_dump($response['headers']);
|
||||
$this->assertEquals('http://localhost/success', $response['headers']['location']);
|
||||
$this->assertEquals("\n", $response['body']);
|
||||
|
||||
return ['session' => $session];
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testLoginSuccess
|
||||
*/
|
||||
public function testLogoutSuccess($data)
|
||||
{
|
||||
$response = $this->client->call(Client::METHOD_DELETE, '/auth/logout', [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'cookie' => 'a-session-console=' . $data['session'],
|
||||
], []);
|
||||
|
||||
var_dump($response);
|
||||
$this->assertEquals('http://localhost/success', $response['headers']['location']);
|
||||
$this->assertEquals("\n", $response['body']);
|
||||
}
|
||||
|
||||
// public function testLogoutFailure()
|
||||
// {
|
||||
// $response = $this->client->call(Client::METHOD_DELETE, '/auth/logout', [
|
||||
// 'origin' => 'http://localhost',
|
||||
// 'content-type' => 'application/json',
|
||||
// ], []);
|
||||
|
||||
// $this->assertEquals('401', $response['body']['code']);
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user