public function invitespost() { $f3 = \Base::instance(); $this->_requireLogin(); $this->_requireRank('support'); $email = $f3->get('POST.inviteEmail'); if ($email == null) { $email = ''; } $key = \Helpers\Invites::createInvite($email, true, 1); new Notification('Invite created. Key: ' . $key, 'success', true); $f3->reroute($f3->get('PATH')); }
public function claimpost() { $f3 = \Base::instance(); if ($f3->get('user')) { if ($f3->get('user')['rank'] == 1) { new Notification('You cannot claim an invite while logged in.', 'danger', true); $f3->reroute('/dashboard'); return; } } $key = $f3->get('PARAMS.invite'); if (\Helpers\Invites::isValidKey($key)) { if ($f3->get('POST.register-password') != $f3->get('POST.register-password-verify')) { $f3->set('errors', ['Password verify must match the first password.']); } else { $user = User::createUser(array('name' => $f3->get("POST.register-name"), 'username' => $f3->get("POST.register-username"), 'email' => $f3->get("POST.register-email"), 'password' => $f3->get("POST.register-password"))); // Data missing if ($user == false) { $f3->set('errors', ['Some information has not been entered correctly or is not long enough.']); } elseif (is_array($user)) { $f3->set('errors', $user); } else { $f3->set('SESSION.id', $user->id); // Delete the key \Helpers\Invites::deleteInvite($key); // Send a mail $f3->set('tplData', ['name' => $f3->get("POST.register-username")]); SendingAPI::send(['mailTo' => $f3->get("POST.register-email"), 'mailSubject' => 'Thank you for registering on SquareMS !', 'mailContents' => ['html' => \Template::instance()->render('mails/register.html'), 'text' => "Thank you for registering on SquareMS ! \n" . "You can access your account now on https://squarems.net/ ! \n\n" . "Please do not respond to this email, it is sent by an automated system."]]); $f3->reroute("/dashboard"); return; } } $f3->set('css', array('/static/css/auth.css')); $f3->set('target', 'invite.html'); $this->_render('base.html'); } else { $f3->error(404); } }