diff --git a/.gitignore b/.gitignore index 4349d8b..bdc750e 100755 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ *~ .*.sw* old -data/config.php +data/ diff --git a/TODO b/TODO index 9381b1d..dd16761 100755 --- a/TODO +++ b/TODO @@ -3,7 +3,6 @@ * htmlspecialchars => on users objects * handle negative amounts * Refactor load method to avoir load_* methods ! -* Empêcher deux fois le même login install.php : ============= diff --git a/inc/Ban.inc.php b/inc/Ban.inc.php index fb3337d..e9dcd4b 100644 --- a/inc/Ban.inc.php +++ b/inc/Ban.inc.php @@ -1,15 +1,15 @@ load_users(array('login'=>$this->login))) == 0) { + return true; + } + else { + return false; + } + } } diff --git a/index.php b/index.php index 28530fc..7104aab 100644 --- a/index.php +++ b/index.php @@ -6,7 +6,7 @@ require_once('inc/Invoices.class.php'); require_once('inc/rain.tpl.class.php'); require_once('inc/functions.php'); - require_once('inc/Banc.inc.php'); + require_once('inc/Ban.inc.php'); require_once('inc/CSRF.inc.php'); raintpl::$tpl_dir = 'tpl/'; raintpl::$cache_dir = 'tmp/'; @@ -150,10 +150,15 @@ $user->setPassword($user->encrypt($_POST['password'])); } $user->setAdmin($_POST['admin']); - $user->save(); - header('location: index.php?do=edit_users'); - exit(); + if($user->isUnique()) { + $user->save(); + header('location: index.php?do=edit_users'); + exit(); + } + else { + $tpl->assign('error', 'A user with the same login exists. Choose a different login.'); + } } } diff --git a/tpl/edit_users.html b/tpl/edit_users.html index 728823f..5ba3f47 100644 --- a/tpl/edit_users.html +++ b/tpl/edit_users.html @@ -29,6 +29,7 @@ {elseif condition="$view == 'edit_user'"}

Edit a user

+{if condition="$error"}

{$error}

{/if}

diff --git a/tpl/settings.html b/tpl/settings.html index 8f19e8d..cfbd41f 100644 --- a/tpl/settings.html +++ b/tpl/settings.html @@ -2,6 +2,7 @@ {if condition="!$show_settings"}

Edit homepage notice

+{if condition="$error"}

{$error}

{/if}


@@ -15,8 +16,8 @@

{else} -

Change settings of your Bouffe@Ulm installation

+{if condition="$error"}

{$error}

{/if}
Database