Routing Fix + E-Mail Confirm frontend
This commit is contained in:
parent
86f9e12b87
commit
db63b55a70
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Api;
|
namespace Api;
|
||||||
|
|
||||||
use Driver\SQL\Condition\Compare;
|
|
||||||
use Driver\SQL\Condition\CondBool;
|
use Driver\SQL\Condition\CondBool;
|
||||||
|
|
||||||
class Stats extends Request {
|
class Stats extends Request {
|
||||||
|
@ -544,17 +544,21 @@ namespace Api\User {
|
|||||||
$this->success = $req->execute(array("token" => $token));
|
$this->success = $req->execute(array("token" => $token));
|
||||||
$this->lastError = $req->getLastError();
|
$this->lastError = $req->getLastError();
|
||||||
|
|
||||||
$result = $req->getResult();
|
if ($this->success) {
|
||||||
if (strcasecmp($result["token"]["type"], "invite") !== 0) {
|
$result = $req->getResult();
|
||||||
return $this->createError("Invalid token type");
|
if (strcasecmp($result["token"]["type"], "email_confirm") !== 0) {
|
||||||
} else if($result["user"]["confirmed"]) {
|
return $this->createError("Invalid token type");
|
||||||
return $this->createError("Your email address is already confirmed.");
|
} else if($result["user"]["confirmed"]) {
|
||||||
} else if (!$this->updateUser($result["user"]["uid"])) {
|
return $this->createError("Your email address is already confirmed.");
|
||||||
return false;
|
} else if (!$this->updateUser($result["user"]["uid"])) {
|
||||||
} else {
|
return false;
|
||||||
$this->invalidateToken($token);
|
} else {
|
||||||
return true;
|
$this->invalidateToken($token);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,17 +8,19 @@ use Elements\View;
|
|||||||
abstract class AccountView extends View {
|
abstract class AccountView extends View {
|
||||||
|
|
||||||
protected string $description;
|
protected string $description;
|
||||||
|
protected string $icon;
|
||||||
|
|
||||||
public function __construct(Document $document, $loadView = true) {
|
public function __construct(Document $document, $loadView = true) {
|
||||||
parent::__construct($document, $loadView);
|
parent::__construct($document, $loadView);
|
||||||
$this->description = "";
|
$this->description = "";
|
||||||
|
$this->icon = "image";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCode() {
|
public function getCode() {
|
||||||
$html = parent::getCode();
|
$html = parent::getCode();
|
||||||
|
|
||||||
$content = $this->getAccountContent();
|
$content = $this->getAccountContent();
|
||||||
$icon = $this->createIcon("user-plus", "fas", "fa-3x");
|
$icon = $this->createIcon($this->icon, "fas", "fa-3x");
|
||||||
|
|
||||||
$html .= "<div class=\"container mt-5\">
|
$html .= "<div class=\"container mt-5\">
|
||||||
<div class=\"row\">
|
<div class=\"row\">
|
||||||
|
@ -5,17 +5,42 @@ namespace Views\Account;
|
|||||||
|
|
||||||
|
|
||||||
use Elements\Document;
|
use Elements\Document;
|
||||||
use Elements\View;
|
|
||||||
|
|
||||||
class ConfirmEmail extends View {
|
class ConfirmEmail extends AccountView {
|
||||||
|
|
||||||
|
private bool $success;
|
||||||
|
private string $message;
|
||||||
|
|
||||||
public function __construct(Document $document, $loadView = true) {
|
public function __construct(Document $document, $loadView = true) {
|
||||||
parent::__construct($document, $loadView);
|
parent::__construct($document, $loadView);
|
||||||
|
$this->title = "Confirm Email";
|
||||||
|
$this->icon = "user-check";
|
||||||
|
$this->success = false;
|
||||||
|
$this->message = "No content";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCode() {
|
public function loadView() {
|
||||||
$html = parent::getCode();
|
parent::loadView();
|
||||||
|
|
||||||
return $html;
|
if (isset($_GET["token"]) && is_string($_GET["token"]) && !empty($_GET["token"])) {
|
||||||
|
$req = new \Api\User\ConfirmEmail($this->getDocument()->getUser());
|
||||||
|
$this->success = $req->execute(array("token" => $_GET["token"]));
|
||||||
|
if ($this->success) {
|
||||||
|
$this->message = "Your e-mail address was successfully confirmed, you may now log in";
|
||||||
|
} else {
|
||||||
|
$this->message = "Error confirming e-mail address: " . $req->getLastError();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->success = false;
|
||||||
|
$this->message = "The link you visited is no longer valid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getAccountContent() {
|
||||||
|
if ($this->success) {
|
||||||
|
return $this->createSuccessText($this->message);
|
||||||
|
} else {
|
||||||
|
return $this->createErrorText($this->message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,6 +13,7 @@ class Register extends AccountView {
|
|||||||
parent::__construct($document, $loadView);
|
parent::__construct($document, $loadView);
|
||||||
$this->title = "Registration";
|
$this->title = "Registration";
|
||||||
$this->description = "Create a new account";
|
$this->description = "Create a new account";
|
||||||
|
$this->icon = "user-plus";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadView() {
|
public function loadView() {
|
||||||
@ -37,19 +38,31 @@ class Register extends AccountView {
|
|||||||
|
|
||||||
return "<h4 class=\"pb-4\">Please fill with your details</h4>
|
return "<h4 class=\"pb-4\">Please fill with your details</h4>
|
||||||
<form>
|
<form>
|
||||||
<div class=\"form-group\">
|
<div class=\"input-group\">
|
||||||
|
<div class=\"input-group-append\">
|
||||||
|
<span class=\"input-group-text\"><i class=\"fas fa-hashtag\"></i></span>
|
||||||
|
</div>
|
||||||
<input id=\"username\" name=\"username\" placeholder=\"Username\" class=\"form-control\" type=\"text\" maxlength=\"32\">
|
<input id=\"username\" name=\"username\" placeholder=\"Username\" class=\"form-control\" type=\"text\" maxlength=\"32\">
|
||||||
</div>
|
</div>
|
||||||
<div class=\"form-group\">
|
<div class=\"input-group mt-3\">
|
||||||
|
<div class=\"input-group-append\">
|
||||||
|
<span class=\"input-group-text\"><i class=\"fas fa-at\"></i></span>
|
||||||
|
</div>
|
||||||
<input type=\"email\" name='email' id='email' class=\"form-control\" placeholder=\"Email\" maxlength=\"64\">
|
<input type=\"email\" name='email' id='email' class=\"form-control\" placeholder=\"Email\" maxlength=\"64\">
|
||||||
</div>
|
</div>
|
||||||
<div class=\"form-group\">
|
<div class=\"input-group mt-3\">
|
||||||
|
<div class=\"input-group-append\">
|
||||||
|
<span class=\"input-group-text\"><i class=\"fas fa-key\"></i></span>
|
||||||
|
</div>
|
||||||
<input type=\"password\" name='password' id='password' class=\"form-control\" placeholder=\"Password\">
|
<input type=\"password\" name='password' id='password' class=\"form-control\" placeholder=\"Password\">
|
||||||
</div>
|
</div>
|
||||||
<div class=\"form-group\">
|
<div class=\"input-group mt-3\">
|
||||||
|
<div class=\"input-group-append\">
|
||||||
|
<span class=\"input-group-text\"><i class=\"fas fa-key\"></i></span>
|
||||||
|
</div>
|
||||||
<input type=\"password\" name='confirmPassword' id='confirmPassword' class=\"form-control\" placeholder=\"Confirm Password\">
|
<input type=\"password\" name='confirmPassword' id='confirmPassword' class=\"form-control\" placeholder=\"Confirm Password\">
|
||||||
</div>
|
</div>
|
||||||
<div class=\"form-group\">
|
<div class=\"input-group mt-3\">
|
||||||
<button type=\"button\" class=\"btn btn-success\" id='btnRegister'>Submit</button>
|
<button type=\"button\" class=\"btn btn-success\" id='btnRegister'>Submit</button>
|
||||||
</div>
|
</div>
|
||||||
</form>";
|
</form>";
|
||||||
|
@ -77,6 +77,14 @@ if(isset($_GET["api"]) && is_string($_GET["api"])) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$requestedUri = $_GET["site"] ?? $_SERVER["REQUEST_URI"];
|
$requestedUri = $_GET["site"] ?? $_SERVER["REQUEST_URI"];
|
||||||
|
if (($index = strpos($requestedUri, "?")) !== false) {
|
||||||
|
$requestedUri = substr($requestedUri, 0, $index);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($index = strpos($requestedUri, "#")) !== false) {
|
||||||
|
$requestedUri = substr($requestedUri, 0, $index);
|
||||||
|
}
|
||||||
|
|
||||||
if (startsWith($requestedUri, "/")) {
|
if (startsWith($requestedUri, "/")) {
|
||||||
$requestedUri = substr($requestedUri, 1);
|
$requestedUri = substr($requestedUri, 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user