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

55 lines
1.9 KiB
PHP
Raw Normal View History

2020-06-20 15:49:53 +02:00
<?php
namespace Views\Account;
use Elements\Document;
2021-11-11 14:25:26 +01:00
use Elements\Script;
2020-06-20 15:49:53 +02:00
2020-07-01 23:07:00 +02:00
class ConfirmEmail extends AccountView {
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";
2021-11-11 14:25:26 +01:00
$this->description = "Request a password reset, once you got the e-mail address, you can choose a new password";
2020-07-01 23:07:00 +02:00
$this->icon = "user-check";
2020-06-20 15:49:53 +02:00
}
2020-07-01 23:07:00 +02:00
public function loadView() {
parent::loadView();
2021-11-11 14:25:26 +01:00
$this->getDocument()->getHead()->addScript(Script::MIME_TEXT_JAVASCRIPT, "", '
$(document).ready(function() {
var token = jsCore.getParameter("token");
if (token) {
jsCore.apiCall("/user/confirmEmail", { token: token }, (res) => {
$("#confirm-status").removeClass("alert-info");
if (!res.success) {
$("#confirm-status").addClass("alert-danger");
$("#confirm-status").text("Error confirming e-mail address: " + res.msg);
} else {
$("#confirm-status").addClass("alert-success");
$("#confirm-status").text("Your e-mail address was successfully confirmed, you may now log in.");
}
});
} else {
$("#confirm-status").removeClass("alert-info");
$("#confirm-status").addClass("alert-danger");
$("#confirm-status").text("The link you visited is no longer valid");
}
});'
);
2020-07-01 23:07:00 +02:00
}
2020-06-20 15:49:53 +02:00
2020-07-01 23:07:00 +02:00
protected function getAccountContent() {
2021-11-11 14:25:26 +01:00
$spinner = $this->createIcon("spinner");
$html = "<noscript><div class=\"alert alert-danger\">Javascript is required</div></noscript>
<div class=\"alert alert-info\" id=\"confirm-status\">
Confirming email… $spinner
</div>";
$html .= "<a href='/login'><button class='btn btn-primary' style='position: absolute; bottom: 10px' type='button'>Proceed to Login</button></a>";
return $html;
2020-06-20 15:49:53 +02:00
}
}