summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorSimon Rettberg2015-03-04 18:43:06 +0100
committerSimon Rettberg2015-03-04 18:43:06 +0100
commit7b17223904214024018f626715926fa729941d3c (patch)
tree6d9fd93915726600ed6c430d1e2e64af87528ef1 /modules
parentThird Commit (diff)
downloadbwlp-webadmin-7b17223904214024018f626715926fa729941d3c.tar.gz
bwlp-webadmin-7b17223904214024018f626715926fa729941d3c.tar.xz
bwlp-webadmin-7b17223904214024018f626715926fa729941d3c.zip
Fourth Commit
Diffstat (limited to 'modules')
-rw-r--r--modules/edit.inc.php41
-rw-r--r--modules/login.inc.php7
-rw-r--r--modules/main.inc.php74
-rw-r--r--modules/register.inc.php2
4 files changed, 102 insertions, 22 deletions
diff --git a/modules/edit.inc.php b/modules/edit.inc.php
new file mode 100644
index 0000000..e3770ce
--- /dev/null
+++ b/modules/edit.inc.php
@@ -0,0 +1,41 @@
+<?php
+
+class Page_Edit extends Page
+{
+
+ public function doPreprocess()
+ {
+ if (!User::load()) {
+ Message::addError('Sie sind nicht angemeldet');
+ Util::redirect('?do=Main');
+ }
+ // See which attributes we are allowed to edit
+ $shib = User::isShibbolethAuth();
+ $pw1 = Request::post('pass1');
+ $pw2 = Request::post('pass2');
+ $mail = Request::post('email');
+ if ((!empty($pw1) || !empty($pw2)) && !$shib) {
+ if ($pw1 !== $pw2) {
+ Message::addError('Ihr Passwort wurde nicht verändert, da die Passwortwiederholung nicht mit dem Passwort übereinstimmt');
+ } else if (mb_strlen($pw1) < 3) {
+ Message::addError('Ihr Passwort ist zu kurz');
+ } else if (!User::updatePassword($pw1)) {
+ Message::addError('Datenbankfehler beim Aktualisieren des Passworts');
+ } else {
+ Message::addSuccess('Ihr Passwort wurde aktualisiert und ist ab sofort gültig');
+ }
+ }
+ if ($mail !== false && $mail !== User::getMail()) {
+ $mail = trim($mail);
+ if (!preg_match('/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}/i', $mail)) {
+ Message::addError('Ihre e-Mail-Adresse wurde nicht aktualisiert, da Sie ein ungültiges Format hat');
+ } else {
+ User::updateMail($mail);
+ Message::addSuccess('Ihr e-Mail-Adresse wurde aktualisiert');
+ }
+ }
+ Util::redirect('?do=Main');
+ }
+
+}
+
diff --git a/modules/login.inc.php b/modules/login.inc.php
index 517ce4e..37b005f 100644
--- a/modules/login.inc.php
+++ b/modules/login.inc.php
@@ -7,6 +7,13 @@ class Page_Login extends Page
{
if (User::load())
Util::redirect('?do=Main');
+ if (Request::post('action') === 'login') {
+ if (User::login(Request::post('user'), Request::post('pass')))
+ Util::redirect('?do=Main');
+ sleep(2);
+ Message::addError('Benutzername oder Passwort falsch');
+ Util::redirect('?do=Login');
+ }
}
public function doRender()
diff --git a/modules/main.inc.php b/modules/main.inc.php
index 3f77d7b..c1382e6 100644
--- a/modules/main.inc.php
+++ b/modules/main.inc.php
@@ -11,30 +11,62 @@ class Page_Main extends Page
protected function doRender()
{
Render::addTemplate('main/_page');
- if (User::isLoggedIn()) {
- // Logged in user --
- if (User::getOrganization() !== false) {
- // Organization is known, show signup form
- if (User::isShibbolethAuth() && !User::isInDatabase()) {
- // User comes via Shibboleth and is not known yet
- $data = User::getData();
- $data['organization'] = User::getOrganizationName();
- Render::addTemplate('main/deploy', $data);
- } else if (User::isInDatabase()) {
- // User is known from DB at least
- Render::addTemplate('main/logged-in');
- }
- } else if (User::getRemoteOrganizationId() !== false) {
- // Organization is not known, see if we at least have an idea
- Message::addWarning('Ihre Hochschule/Einrichtung {{0}} ist leider nicht bekannt. Bitte kontaktieren Sie den Support.', User::getRemoteOrganizationId());
- } else {
- // No idea where the user is coming from
- Message::addError('Ihr IdP sendet leider keine Informationen über Ihre Hochschul-/Einrichtungszugehörigkeit');
- }
- } else {
+ if (!User::isLoggedIn()) {
// Guest
Render::addTemplate('main/guest');
+ return;
+ }
+ // Logged in user --
+ if (User::isLocalOnly()) {
+ // Local test account
+ $this->renderLocalAccount();
+ return;
+ }
+ if (!User::isShibbolethAuth()) {
+ // Should not be possible
+ Message::addError('Sie sind nicht korrekt authentifiziert. Bitte melden Sie sich erneut an.');
+ Session::delete();
+ return;
+ }
+ // --- Below here we know the user via shibboleth
+ if (User::isInDatabase()) {
+ // User is also in DB, so he signed up for the service
+ $this->renderShibbolethRegistered();
+ return;
}
+ // User is not in DB, so he might want so sign up for the service - see if conditions are met
+ if (User::getOrganization() !== false) {
+ // Organization is known, show signup form
+ $this->renderShibbolethUnregistered();
+ return;
+ }
+ // Nothing we can do here, show error message :-(
+ if (User::getRemoteOrganizationId() !== false) {
+ // Organization is not known, see if we at least have an idea
+ Message::addWarning('Ihre Hochschule/Einrichtung {{0}} ist leider nicht bekannt. Bitte kontaktieren Sie den Support.', User::getRemoteOrganizationId());
+ } else {
+ // No idea where the user is coming from
+ Message::addError('Ihr IdP sendet leider keine Informationen über Ihre Hochschul-/Einrichtungszugehörigkeit');
+ }
+ }
+
+ private function renderShibbolethRegistered()
+ {
+ Render::addTemplate('main/logged-in');
+ }
+
+ private function renderShibbolethUnregistered()
+ {
+ $data = User::getData();
+ $data['organization'] = User::getOrganizationName();
+ Render::addTemplate('main/deploy', $data);
+ }
+
+ private function renderLocalAccount()
+ {
+ $data = User::getData();
+ $data['organization'] = User::getOrganizationName();
+ Render::addTemplate('main/logged-in-testacc', $data);
}
}
diff --git a/modules/register.inc.php b/modules/register.inc.php
index ca5f4bf..3dd3b89 100644
--- a/modules/register.inc.php
+++ b/modules/register.inc.php
@@ -11,7 +11,7 @@ class Page_Register extends Page
Util::redirect('?do=Main');
}
if (!User::isShibbolethAuth())
- Util::redirect('/secure-all/?do=Main');
+ Util::redirect(CONFIG_PREFIX . 'shib/?do=Main');
if (Request::post('agb') === 'on') {
// Put stuff in DB
User::deploy(Request::post('share') !== 'on');