restructuring auth method keys

This commit is contained in:
Damodar Lohani
2021-08-06 13:46:53 +05:45
parent 851a00e438
commit 6f540fec0f
4 changed files with 13 additions and 13 deletions
+5 -5
View File
@@ -5,35 +5,35 @@
return [
'email-password' => [
'name' => 'Email/Password',
'key' => 'usersAuthEmailPassword',
'key' => 'emailPassword',
'icon' => '/images/users/email.png',
'docs' => 'https://appwrite.io/docs/client/account?sdk=web#accountCreateSession',
'enabled' => true,
],
'anonymous' => [
'name' => 'Anonymous',
'key' => 'usersAuthAnonymous',
'key' => 'anonymous',
'icon' => '/images/users/anonymous.png',
'docs' => 'https://appwrite.io/docs/client/account?sdk=web#accountCreateAnonymousSession',
'enabled' => true,
],
'invites' => [
'name' => 'Invites',
'key' => 'usersAuthInvites',
'key' => 'invites',
'icon' => '/images/users/invites.png',
'docs' => 'https://appwrite.io/docs/client/teams?sdk=web#teamsCreateMembership',
'enabled' => true,
],
'jwt' => [
'name' => 'JWT',
'key' => 'usersAuthJWT',
'key' => 'JWT',
'icon' => '/images/users/jwt.png',
'docs' => 'https://appwrite.io/docs/client/account?sdk=web#accountCreateJWT',
'enabled' => true,
],
'phone' => [
'name' => 'Phone',
'key' => 'usersAuthPhone',
'key' => 'phone',
'icon' => '/images/users/phone.png',
'docs' => 'https://appwrite.io/docs/client/account?sdk=web#accountCreatePhoneSession',
'docs' => '',
+4 -4
View File
@@ -140,25 +140,25 @@ App::init(function ($utopia, $request, $response, $project, $user) {
$auths = $project->getAttribute('auths', []);
switch ($route->getLabel('auth.type', '')) {
case 'emailPassword':
if(($auths['usersAuthEmailPassword'] ?? true) === false) {
if(($auths['emailPassword'] ?? true) === false) {
throw new Exception('Email / Password authentication is disabled for this project', 501);
}
break;
case 'anonymous':
if(($auths['usersAuthAnonymous'] ?? true) === false) {
if(($auths['anonymous'] ?? true) === false) {
throw new Exception('Anonymous authentication is disabled for this project', 501);
}
break;
case 'invites':
if(($auths['usersAuthInvites'] ?? true) === false) {
if(($auths['invites'] ?? true) === false) {
throw new Exception('Invites authentication is disabled for this project', 501);
}
break;
case 'jwt':
if(($auths['usersAuthJWT'] ?? true) === false) {
if(($auths['JWT'] ?? true) === false) {
throw new Exception('JWT authentication is disabled for this project', 501);
}
break;
@@ -158,7 +158,7 @@ class Project extends Model
$key = $method['key'] ?? '';
$this
->addRule($key, [
->addRule('auth' . ucfirst($key), [
'type' => self::TYPE_BOOLEAN,
'description' => $name.' auth method status',
'example' => true,
@@ -229,9 +229,9 @@ class Project extends Model
$auth = Config::getParam('auth', []);
foreach ($auth as $index => $method) {
$key = $method['key'] ?? '';
$key = $method['key'];
$value = $authValues[$key] ?? true;
$document->setAttribute($key, $value);
$document->setAttribute('auth' . ucfirst($key), $value);
}
return $document;
@@ -351,7 +351,7 @@ class ProjectsConsoleClientTest extends Scope
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(false, $response['body'][$method['key']]);
$this->assertEquals(false, $response['body']['auth'. ucfirst($method['key'])]);
}
$email = uniqid().'user@localhost.test';