web-base/core/Views/Account/ConfirmEmail.class.php

46 lines
1.2 KiB
PHP
Raw Normal View History

2020-06-20 15:49:53 +02:00
<?php
namespace Views\Account;
use Elements\Document;
2020-07-01 23:07:00 +02:00
class ConfirmEmail extends AccountView {
private bool $success;
private string $message;
2020-06-20 15:49:53 +02:00
public function __construct(Document $document, $loadView = true) {
parent::__construct($document, $loadView);
2020-07-01 23:07:00 +02:00
$this->title = "Confirm Email";
$this->icon = "user-check";
$this->success = false;
$this->message = "No content";
2020-06-20 15:49:53 +02:00
}
2020-07-01 23:07:00 +02:00
public function loadView() {
parent::loadView();
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";
}
}
2020-06-20 15:49:53 +02:00
2020-07-01 23:07:00 +02:00
protected function getAccountContent() {
if ($this->success) {
return $this->createSuccessText($this->message);
} else {
return $this->createErrorText($this->message);
}
2020-06-20 15:49:53 +02:00
}
}