Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf527e55 authored by Israel Yago Pereira's avatar Israel Yago Pereira Committed by Nivesh Krishna
Browse files

Referral link

parent 6932a880
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -29,9 +29,19 @@ $pw2 = $_POST['repassword'];
$name = $_POST['displayname'];
$authmail = $_POST['authmail'];
$authsecret = $_POST['authsecret'];
$referrerCode = isset($_POST["ref"]) ? $_POST["ref"] : null;
$referrerCode = is_string($referrerCode) ? $referrerCode : null;
$resultmail = $mbox . "@" . $mail_domain;

if (strlen($mbox) > 30 || strlen($name) > 30 || strlen($pw) > 1024 || strlen($pw2) > 1024 || strlen($authmail) > 1024 || strlen($authsecret) > 1024) {
if (
    strlen($mbox) > 30 || 
    strlen($name) > 30 || 
    strlen($pw) > 1024 || 
    strlen($pw2) > 1024 || 
    strlen($authmail) > 1024 || 
    strlen($authsecret) > 1024 ||
    is_string($referrerCode) && strlen($referrerCode) > 1024
    ) {
    $error_string = $strings["error_input_too_large"];
    sendAPIResponse(400, createAPIResponse("general", $error_string));
}
@@ -76,6 +86,7 @@ $userData->username = $mbox;
$userData->email = $resultmail;
$userData->authmail = $authmail;
$userData->password = $pw;
$userData->referrerCode = $referrerCode;

$accountsCreators = getAccountsCreators($domain);
validateAccountOnAllServices($accountsCreators, $userData);
+2 −2
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ class ECloudAccountCreator implements AccountCreator
        return $answer;
    }

    private function createMailAccount($resultmail, $pw, $pw2, $name, $quota, $authmail)
    private function createMailAccount($resultmail, $pw, $pw2, $name, $quota, $authmail, ?string $referrerCode = null)
    {
        global $strings;
        $PF_HOSTNAME = "postfixadmin";
@@ -135,7 +135,7 @@ class ECloudAccountCreator implements AccountCreator
    {
        global $strings;
        $pw = $userData->password;
        $answer = $this->createMailAccount($userData->email, $pw, $pw, $userData->name, $this->quotaInMB, $userData->authmail);
        $answer = $this->createMailAccount($userData->email, $pw, $pw, $userData->name, $this->quotaInMB, $userData->authmail, $userData->referrerCode);
        if ($answer->success === false) {
            sendAPIResponse(400, createAPIResponse("general", $strings[$answer->type]));
        }
+6 −0
Original line number Diff line number Diff line
@@ -68,6 +68,12 @@ flags:
        </div>
      </div>

      <input
        class="requestInput"
        id="ref"
        name="ref"
        type="hidden"
      />
      <div class="field has-text-centered" id="buttonField">
        <div class="control">
          <button class="button is-rounded" id="submitButton" type="submit">
+4 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ function isEmailDomainBlackListed($email): bool
    return in_array($domain, $blacklisted);
}

function sendInviteMail($to, $secret, $lang)
function sendInviteMail($to, $secret, $lang, ?string $referrer = null)
{
    $encoded_email = urlencode($to);
    $domain = getenv("DOMAIN");
@@ -44,6 +44,9 @@ function sendInviteMail($to, $secret, $lang)
        $signupURL .= "$lang/";
    }
    $signupURL .= "register?authmail=$encoded_email&authsecret=$secret";
    if ($referrer != null) {
        $signupURL .= "&ref=$referrer";
    }
    $SENDGRID_API_KEY = getenv("SENDGRID_API_KEY");
    if (!empty($SENDGRID_API_KEY)) {
        return sendInviteMailWithSendGrid($to, $signupURL);
+3 −5
Original line number Diff line number Diff line
<?php
$domain = getenv("DOMAIN");
$qs = $_SERVER['QUERY_STRING'];

if (strpos($qs, "authmail") !== false && strpos($qs, "authsecret") !== false) {
    header("Location: https://welcome.$domain/register?" . $qs);
    die();
    header("Location: /register?" . $qs);
} else {
    header("Location: https://welcome.$domain/e-email-invite");
    die();
    header("Location: /e-email-invite");
}
die();
Loading