Compare commits

...
Author SHA1 Message Date
Matej Bačo da23a9baa9 Merge remote-tracking branch 'origin/1.5.x' into fix-email-otp 2024-02-02 11:57:40 +00:00
Matej Bačo d95fdc18a7 Merge branch 'main' into fix-email-otp 2024-02-02 11:31:38 +00:00
Matej Bačo 2f2008d188 PR review changes 2024-02-02 11:21:44 +00:00
Jake BarnbyandGitHub 26b2c27eb0 Merge pull request #7531 from appwrite/remove-debug-sn
remove debug leftovers
2024-02-01 21:38:26 +13:00
shimon 62bc540db0 removed var_dump leftovers 2024-02-01 10:35:38 +02:00
shimon 1ef5c9bfcd removed var_dump leftovers 2024-02-01 10:32:40 +02:00
Matej Bačo 769a582b72 Fix failing test 2024-01-26 11:10:05 +00:00
Matej Bačo 70ad2731a3 More bug fixes 2024-01-26 10:51:40 +00:00
Matej Bačo 00cf9c9ac2 QA fixes 2024-01-26 10:14:59 +00:00
Matej Bačo f581147601 Disabled otp signin support 2024-01-26 09:20:46 +01:00
17 changed files with 34 additions and 132 deletions
-6
View File
@@ -241,11 +241,5 @@
"emails.otpSession.securityPhrase": "এই ইমেইলৰ সুৰক্ষা বাক্যটো হৈছে {{phrase}}। আপুনি এই ইমেইলটোত আস্থা ৰাখিব পাৰে যদি প্ৰবেশৰ সময়ত দেখুৱাই থকা বাক্যটোৰ লগত এই বাক্যটো মেলে।",
"emails.otpSession.thanks": "ধন্যবাদ,",
"emails.otpSession.signature": "{{project}} দল",
"emails.certificate.subject": "%sৰ বাবে প্ৰমাণপত্ৰ ব্যৰ্থতা",
"emails.certificate.hello": "নমস্কাৰ",
"emails.certificate.body": "আপোনাৰ ডোমেইন '{{domain}}' ৰ বাবে প্ৰমাণপত্ৰটো উত্‌পন্ন কৰিব পৰা নগ'ল। এয়া প্ৰচেষ্টা নম্বৰ {{attempt}}, আৰু বিফলতাৰ কাৰণ হ'ল: {{error}}",
"emails.certificate.footer": "আপোনাৰ পূৰ্বৰ প্ৰমাণপত্ৰটো প্ৰথম ব্ৰিফল হোৱাৰ দিনৰ পৰা ৩০ দিনলৈ বৈধ থাকিব। আমি এই ঘটনাটোৰ তদন্ত কৰিবলৈ উচ্চ পৰামৰ্শ দিয়ে, অন্যথা আপোনাৰ ডোমেইনটো অবৈধ SSL যোগাযোগ অবিহনে থাকিব।",
"emails.certificate.thanks": "ধন্যবাদ",
"emails.certificate.signature": "{{project}} দল",
"sms.verification.body": "{{secret}} আপোনাৰ {{project}} যাচাইকৰণ কোড।"
}
-6
View File
@@ -241,11 +241,5 @@
"emails.otpSession.securityPhrase": "Фраза бяспекі для гэтага ліста - {{phrase}}. Вы можаце давяраць гэтаму лісту, калі гэтая фраза супадае з фразай, паказанай пры ўваходзе.",
"emails.otpSession.thanks": "Дзякуй,",
"emails.otpSession.signature": "каманда {{project}}",
"emails.certificate.subject": "Сведчанне няўдалае для %s",
"emails.certificate.hello": "Прывітанне",
"emails.certificate.body": "Сертыфікат для вашага дамена '{{domain}}' не можа быць створаны. Гэта спроба нумар {{attempt}}, і прычынай няўдачы з'яўляецца: {{error}}",
"emails.certificate.footer": "Ваш папярэдні сертыфікат будзе дзейнічаць 30 дзён з моманту першай няўдачы. Мы высока рэкамендуем расследаваць гэтую сітуацыю, інакш ваш дамен апынецца без дзейнага сертыфіката SSL-злучэння.",
"emails.certificate.thanks": "Дзякуй",
"emails.certificate.signature": "каманда {{project}}",
"sms.verification.body": "{{secret}} з'яўляецца вашым кодам праверкі для {{project}}."
}
-6
View File
@@ -241,11 +241,5 @@
"emails.otpSession.securityPhrase": "एही ईमेल खातिर सुरक्षा वाक्य {{phrase}} हऽ। अगर ई वाक्य साइन इन कइला के समय देखावल गेल वाक्य से मेल खाता, त एह ईमेल पर भरोसा कर सकैत छी।",
"emails.otpSession.thanks": "धन्यवाद",
"emails.otpSession.signature": "{{project}} टीम",
"emails.certificate.subject": "%s लेल प्रमाणपत्र असफलта",
"emails.certificate.hello": "नमस्ते",
"emails.certificate.body": "आपके डोमेन '{{domain}}' के लिए प्रमाणपत्र नहीं बनाया जा सका। ई प्रयास संख्या {{attempt}} है, और ई असफलता के कारण रहे: {{error}}",
"emails.certificate.footer": "तोहार पिछलका प्रमाणपत्र पहिल असफलता से 30 दिन धरी मान्य होईत। हम बहुत जोर देके सलाह देतानी कि एह मामला के जांच करीं, नहीं त तोहार डोमेन बिना कोनो मान्य SSL संवाद के रहि जाईत।",
"emails.certificate.thanks": "धन्यवाद",
"emails.certificate.signature": "{{project}} टीम",
"sms.verification.body": "{{secret}} आपके {{project}} सत्यापन कोड हवे।"
}
+2 -2
View File
@@ -14,14 +14,14 @@
"emails.magicSession.optionButton": "Click the button below to securely sign in to your {{project}} account. This link will expire in 1 hour.",
"emails.magicSession.buttonText": "Sign in to {{project}}",
"emails.magicSession.optionUrl": "If you are unable to sign in using the button above, please visit the following link:",
"emails.magicSession.clientInfo": "This sign in was requested using {{agentClient}} on {{agentDevice}} {{agentOs}}. If you didn't request the sign in, you can safely ignore this email.",
"emails.magicSession.clientInfo": "This sign in was requested using {{agentClient}} on {{agentDevice}} ({{agentOs}}). If you didn't request the sign in, you can safely ignore this email.",
"emails.magicSession.securityPhrase": "Security phrase for this email is {{phrase}}. You can trust this email if this phrase matches the phrase shown during sign in.",
"emails.magicSession.thanks": "Thanks,",
"emails.magicSession.signature": "{{project}} team",
"emails.otpSession.subject": "OTP for {{project}} Login",
"emails.otpSession.hello": "Hello,",
"emails.otpSession.description": "Enter the following verification code when prompted to securely sign in to your {{project}} account. This code will expire in 15 minutes.",
"emails.otpSession.clientInfo": "This sign in was requested using {{agentClient}} on {{agentDevice}} {{agentOs}}. If you didn't request the sign in, you can safely ignore this email.",
"emails.otpSession.clientInfo": "This sign in was requested using {{agentClient}} on {{agentDevice}} ({{agentOs}}). If you didn't request the sign in, you can safely ignore this email.",
"emails.otpSession.securityPhrase": "Security phrase for this email is {{phrase}}. You can trust this email if this phrase matches the phrase shown during sign in.",
"emails.otpSession.thanks": "Thanks,",
"emails.otpSession.signature": "{{project}} team",
-6
View File
@@ -241,11 +241,5 @@
"emails.otpSession.securityPhrase": "Sententia securitatis huius epistulae est {{phrase}}. Epistulae confidere potes si haec sententia cum ea quae ostensa est in signo ingressus convenit.",
"emails.otpSession.thanks": "Gratias,",
"emails.otpSession.signature": "{{project}} team -> {{project}} grex",
"emails.certificate.subject": "Defectio testimonii pro %s",
"emails.certificate.hello": "Salve",
"emails.certificate.body": "Certificatum pro dominio tuo '{{domain}}' generari non potuit. Hoc conatus num. {{attempt}} est, et defectus causatus est ab: {{error}}",
"emails.certificate.footer": "Praeclarum tuum testificationem valet ad XXX dies a primo defectu. Magnopere suademus ut hoc casum investiges, alioquin dominium tuum sine valida SSL communicatione erit.",
"emails.certificate.thanks": "Gratias",
"emails.certificate.signature": "team {{project}}",
"sms.verification.body": "{{secret}} est codex verificatorius {{project}} tui."
}
-6
View File
@@ -241,11 +241,5 @@
"emails.otpSession.securityPhrase": "ഈ ഇമെയിലിന്റെ സുരക്ഷാ വാചകം {{phrase}} ആണ്. സൈൻ ഇൻ ചെയ്യുമ്പോൾ കാണിച്ച വാചകവുമായി ഈ വാചകം പൊരുത്തപ്പെടുന്നുണ്ടെങ്കിൽ ഈ ഇമെയിലിന് വിശ്വസിക്കാം.",
"emails.otpSession.thanks": "നന്ദി,",
"emails.otpSession.signature": "പ്രോജക്ട് ടീം",
"emails.certificate.subject": "%s ന് സർട്ടിഫിക്കറ്റ് പരാജയപ്പെട്ടു",
"emails.certificate.hello": "ഹലോ",
"emails.certificate.body": "നിങ്ങളുടെ ഡൊമൈൻ '{{domain}}'നു വേണ്ടിയുള്ള സർട്ടിഫിക്കറ്റ് ഉണ്ടാക്കാനായില്ല. ഇത് ശ്രമം നമ്പർ {{attempt}} ആണ്, പരാജയപ്പെട്ടത് ഇതു മൂലമാണ്: {{error}}",
"emails.certificate.footer": "നിങ്ങളുടെ മുൻപത്തെ സർട്ടിഫിക്കറ്റ് ആദ്യ പരാജയത്തിനു ശേഷം 30 ദിവസം വരെ സാധുവായിരിക്കും. ഈ കേസ് അന്വേഷിച്ചു നോക്കുന്നത് ഞങ്ങൾ ശക്തമായി ശുപാർശ ചെയ്യുന്നു, അല്ലെങ്കിൽ നിങ്ങളുടെ ഡൊമെയ്‌ൻ സാധുവായ SSL കമ്മ്യൂണിക്കേഷനില്ലാത്ത ഒരു അവസ്ഥയിലാകും.",
"emails.certificate.thanks": "നന്ദി",
"emails.certificate.signature": "{{project}} ടീം",
"sms.verification.body": "{{secret}} നിങ്ങളുടെ {{project}} പരിശോധന കോഡാണ്."
}
-6
View File
@@ -241,11 +241,5 @@
"emails.otpSession.securityPhrase": "Tryggingsfrasen for denne e-posten er {{phrase}}. Du kan stole på denne e-posten om frasen stemmer med frasen vist under pålogging.",
"emails.otpSession.thanks": "Takk,",
"emails.otpSession.signature": "{{project}}-laget",
"emails.certificate.subject": "Sertifikatfeil for %s",
"emails.certificate.hello": "Hei",
"emails.certificate.body": "Sertifikatet for domenet ditt '{{domain}}' kunne ikkje opprettast. Dette er forsøk nr. {{attempt}}, og feilen blei forårsaka av: {{error}}",
"emails.certificate.footer": "Førre sertifikatet ditt vil vere gyldig i 30 dagar sidan den første feilen. Vi rår sterkt til at du undersøkjer denne saka, elles vil domenet ditt ende opp utan gyldig SSL-kommunikasjon.",
"emails.certificate.thanks": "Takk",
"emails.certificate.signature": "{{project}} team",
"sms.verification.body": "{{secret}} er verifiseringskoden din for {{project}}."
}
-6
View File
@@ -241,11 +241,5 @@
"emails.otpSession.securityPhrase": "هن ای میل لاءِ سیکيورٽي جملو {{phrase}} آھي. توهان هن ای میل تي اعتماد ڪري سگهو ٿا جيڪڏهن هن جملو لاڳو ٿيندڙ جملي سان ميل کاندي.",
"emails.otpSession.thanks": "مهرباني",
"emails.otpSession.signature": "پروجيڪٽ جي ٽيم",
"emails.certificate.subject": "%s لاءِ سند جو ناکامی",
"emails.certificate.hello": "هيلو",
"emails.certificate.body": "توهان جي ڊومين '{{domain}}' لاءِ سرٽيفڪيٽ ٺاهڻ جو نه ٿي سگهيو. هي ڪوشش نمبر {{attempt}} آهي، ۽ ناڪامي جو سبب ٿيو: {{error}}",
"emails.certificate.footer": "توهان جو اڳيون سرٽيفڪيٽ اولهو فئيلر جي ݙينهن کان ٣٠ ݙينهن لاءِ ماني ويندو. اسان ان جي چھان بني جي بھرپور خواهش ڪنداسين، نہ ته توهان جو ݙومين بغير ڪوري SSL ڪميونڪيشن آڻي ويندي.",
"emails.certificate.thanks": "شُكريا",
"emails.certificate.signature": "ٽيم",
"sms.verification.body": "{{secret}} توهان جي {{project}} تصديقي ڪوڊ آهي."
}
+8 -14
View File
@@ -1174,9 +1174,9 @@ App::post('/v1/account/tokens/magic-url')
'team' => '',
'project' => $project->getAttribute('name'),
'redirect' => $url,
'agentDevice' => '<strong>' . ( $agentDevice['deviceBrand'] ?? $agentDevice['deviceBrand'] ?? 'UNKNOWN') . '</strong>',
'agentClient' => '<strong>' . ($agentClient['clientName'] ?? 'UNKNOWN') . '</strong>',
'agentOs' => '<strong>' . ($agentOs['osName'] ?? 'UNKNOWN') . '</strong>',
'agentDevice' => '<strong>' . (!empty($agentDevice['deviceBrand']) ? $agentDevice['deviceBrand'] : 'Unknown device') . '</strong>',
'agentClient' => '<strong>' . (!empty($agentOs['clientName']) ? $agentOs['clientName'] : 'Unknown client') . '</strong>',
'agentOs' => '<strong>' . (!empty($agentOs['osName']) ? $agentOs['osName'] : 'Unknown OS') . '</strong>',
'phrase' => '<strong>' . (!empty($phrase) ? $phrase : '') . '</strong>'
];
@@ -1209,9 +1209,9 @@ App::post('/v1/account/tokens/magic-url')
App::post('/v1/account/tokens/email')
->desc('Create email token (OTP)')
->groups(['api', 'account'])
->groups(['api', 'account', 'auth'])
->label('scope', 'sessions.write')
->label('auth.type', 'email')
->label('auth.type', 'email-otp')
->label('audits.event', 'session.create')
->label('audits.resource', 'user/{response.userId}')
->label('audits.userId', '{response.userId}')
@@ -1402,17 +1402,11 @@ App::post('/v1/account/tokens/email')
'team' => '',
'project' => $project->getAttribute('name'),
'otp' => $tokenSecret,
'agentDevice' => '<strong>' . ( $agentDevice['deviceBrand'] ?? $agentDevice['deviceBrand'] ?? 'UNKNOWN') . '</strong>',
'agentClient' => '<strong>' . ($agentClient['clientName'] ?? 'UNKNOWN') . '</strong>',
'agentOs' => '<strong>' . ($agentOs['osName'] ?? 'UNKNOWN') . '</strong>',
'agentDevice' => '<strong>' . (!empty($agentDevice['deviceBrand']) ? $agentDevice['deviceBrand'] : 'Unknown device') . '</strong>',
'agentClient' => '<strong>' . (!empty($agentOs['clientName']) ? $agentOs['clientName'] : 'Unknown client') . '</strong>',
'agentOs' => '<strong>' . (!empty($agentOs['osName']) ? $agentOs['osName'] : 'Unknown OS') . '</strong>',
'phrase' => '<strong>' . (!empty($phrase) ? $phrase : '') . '</strong>'
];
$queueForMails
->setSubject($subject)
->setBody($body)
->setVariables($emailVariables)
->setRecipient($email)
->trigger();
$queueForEvents->setPayload(
+7 -1
View File
@@ -334,7 +334,13 @@ App::init()
switch ($route->getLabel('auth.type', '')) {
case 'emailPassword':
if (($auths['emailPassword'] ?? true) === false) {
throw new Exception(Exception::USER_AUTH_METHOD_UNSUPPORTED, 'Email / Password authentication is disabled for this project');
throw new Exception(Exception::USER_AUTH_METHOD_UNSUPPORTED, 'Email & Password authentication is disabled for this project');
}
break;
case 'email-otp':
if (($auths['emailOtp'] ?? true) === false) {
throw new Exception(Exception::USER_AUTH_METHOD_UNSUPPORTED, 'Email OTP authentication is disabled for this project');
}
break;
+6
View File
@@ -31,6 +31,12 @@ App::init()
}
break;
case 'email-otp':
if (($auths['emailOtp'] ?? true) === false) {
throw new Exception(Exception::USER_AUTH_METHOD_UNSUPPORTED, 'Email OTP authentication is disabled for this project');
}
break;
case 'magic-url':
if ($project->getAttribute('usersAuthMagicURL', true) === false) {
throw new Exception(Exception::USER_AUTH_METHOD_UNSUPPORTED, 'Magic URL authentication is disabled for this project');
+4 -17
View File
@@ -429,28 +429,14 @@ class Certificates extends Action
// Send mail to administratore mail
$template = Template::fromFile(__DIR__ . '/../../../../app/config/locale/templates/email-certificate-failed.tpl');
$template->setParam('{{domain}}', $domain);
$template->setParam('{{error}}', \nl2br($errorMessage));
$template->setParam('{{error}}', \nl2br($errorMessage), false);
$template->setParam('{{attempts}}', $attempt);
// TODO: Use setbodyTemplate once #7307 is merged
$subject = 'Certificate failed to generate';
$body = Template::fromFile(__DIR__ . '/../../../../app/config/locale/templates/email-base-styled.tpl');
$subject = \sprintf($locale->getText("emails.certificate.subject"), $domain);
$message = Template::fromFile(__DIR__ . '/../../../../app/config/locale/templates/email-inner-base.tpl');
$message
->setParam('{{body}}', $locale->getText("emails.certificate.body"), escapeHtml: false)
->setParam('{{hello}}', $locale->getText("emails.certificate.hello"))
->setParam('{{footer}}', $locale->getText("emails.certificate.footer"))
->setParam('{{thanks}}', $locale->getText("emails.certificate.thanks"))
->setParam('{{signature}}', $locale->getText("emails.certificate.signature"));
$body = $message->render();
$subject = 'Certificate for ' . $domain . ' failed to generate';
$emailVariables = [
'direction' => $locale->getText('settings.direction'),
'domain' => $domain,
'error' => '<br><pre>' . $errorMessage . '</pre>',
'attempt' => $attempt,
'project' => 'Console',
'redirect' => 'https://' . $domain,
@@ -458,7 +444,8 @@ class Certificates extends Action
$queueForMails
->setSubject($subject)
->setBody($body)
->setbodyTemplate(__DIR__ . '/../../../../app/config/locale/templates/email-base-styled.tpl')
->setBody($template->render())
->setName('Appwrite Administrator')
->setVariables($emailVariables)
->setRecipient(App::getEnv('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS'))
+3 -2
View File
@@ -78,8 +78,9 @@ class Mails extends Action
$bodyTemplate = Template::fromFile($bodyTemplate);
$bodyTemplate->setParam('{{body}}', $body, escapeHtml: false);
foreach ($variables as $key => $value) {
// TODO: hotfix for redirect param
$bodyTemplate->setParam('{{' . $key . '}}', $value, escapeHtml: $key !== 'redirect');
// TODO: hotfix for html params
$htmlParams = [ 'redirect', 'agentDevice', 'agentClient', 'agentOs', 'phrase' ];
$bodyTemplate->setParam('{{' . $key . '}}', $value, escapeHtml: !(\in_array($key, $htmlParams)));
}
$body = $bodyTemplate->render();
-11
View File
@@ -70,16 +70,6 @@ class Usage extends Action
getProjectDB: $getProjectDB
);
}
if ($project->getInternalId() == self::DEBUG_PROJECT_ID) {
var_dump([
'type' => 'payload',
'project' => $project->getInternalId(),
'database' => $project['database'] ?? '',
$payload['metrics']
]);
var_dump('==========================');
}
self::$stats[$projectId]['project'] = $project;
foreach ($payload['metrics'] ?? [] as $metric) {
@@ -91,7 +81,6 @@ class Usage extends Action
}
}
/**
* On Documents that tied by relations like functions>deployments>build || documents>collection>database || buckets>files.
* When we remove a parent document we need to deduct his children aggregation from the project scope.
@@ -57,14 +57,6 @@ class UsageHook extends Usage
try {
$dbForProject = $getProjectDB($data['project']);
if ($projectInternalId == 85293) {
var_dump([
'project' => $projectInternalId,
'database' => $database,
'time' => DateTime::now(),
'data' => $data['keys']
]);
}
foreach ($data['keys'] ?? [] as $key => $value) {
if ($value == 0) {
continue;
@@ -75,15 +67,6 @@ class UsageHook extends Usage
$id = \md5("{$time}_{$period}_{$key}");
try {
if ($projectInternalId == self::DEBUG_PROJECT_ID) {
var_dump([
'type' => 'create',
'period' => $period,
'metric' => $key,
'id' => $id,
'value' => $value
]);
}
$dbForProject->createDocument('stats_v2', new Document([
'$id' => $id,
'period' => $period,
@@ -94,15 +77,6 @@ class UsageHook extends Usage
]));
} catch (Duplicate $th) {
if ($value < 0) {
if ($projectInternalId == self::DEBUG_PROJECT_ID) {
var_dump([
'type' => 'decrease',
'period' => $period,
'metric' => $key,
'id' => $id,
'value' => $value
]);
}
$dbForProject->decreaseDocumentAttribute(
'stats_v2',
$id,
@@ -110,15 +84,6 @@ class UsageHook extends Usage
abs($value)
);
} else {
if ($projectInternalId == self::DEBUG_PROJECT_ID) {
var_dump([
'type' => 'increase',
'period' => $period,
'metric' => $key,
'id' => $id,
'value' => $value
]);
}
$dbForProject->increaseDocumentAttribute(
'stats_v2',
$id,
+2 -8
View File
@@ -206,18 +206,12 @@ class Webhooks extends Action
$template->setParam('{{path}}', "/console/project-$projectId/settings/webhooks/$webhookId");
$template->setParam('{{attempts}}', $attempts);
// TODO: Use setbodyTemplate once #7307 is merged
$subject = 'Webhook deliveries have been paused';
$body = Template::fromFile(__DIR__ . '/../../../../app/config/locale/templates/email-base-styled.tpl');
$body
->setParam('{{subject}}', $subject)
->setParam('{{message}}', $template->render())
->setParam('{{year}}', date("Y"));
$queueForMails
->setSubject($subject)
->setBody($body->render());
->setbodyTemplate(__DIR__ . '/../../../../app/config/locale/templates/email-base-styled.tpl')
->setBody($template->render());
foreach ($users as $user) {
$queueForMails
@@ -622,6 +622,8 @@ class ProjectsConsoleClientTest extends Scope
$this->assertEquals(204, $response['headers']['status-code']);
\sleep(5);
$emails = $this->getLastEmail(2);
$this->assertCount(2, $emails);
$this->assertEquals('custommailer@appwrite.io', $emails[0]['from'][0]['address']);