Update user mgmt to allow saml user add by email

This commit is contained in:
2021-05-07 14:36:00 -04:00
parent 0d97c784d1
commit 337efaf2a6
3 changed files with 45 additions and 1 deletions

View File

@@ -178,7 +178,7 @@
header('Location: ' . $_SERVER['PHP_SELF']);
endif;
if (!empty($_POST['newuser'])): // NEW USER
if (!empty($_POST['newuser'])): // NEW USER INTERNAL
require_once("src/Misc/PasswordHash.php");
if (empty($_POST['username'])): $errors['username'] = $transLang['USERNAME_NOTEMPTY']; endif;
if (preg_match('/[^a-zA-Z0-9 .-_]/', $_POST['username'])): $errors['username'] = $transLang['ILLEGAL_CHARACTERS']; endif;
@@ -200,6 +200,20 @@
$Users->addUser($_POST['firstname'], $_POST['lastname'], $_POST['username'], $timezone, $password, $_POST['email'], $_POST['usertype']);
header('Location: ' . $_SERVER['PHP_SELF']);
endif;
if (!empty($_POST['newuser'])): // NEW USER SAML
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
if (!$email): $errors['email'] = $transLang['EMAIL_NOTVALID']; endif;
$existing = $Users->checkUser($email);
if ($existing):
if ($existing[0]["users_email"] == $email): $errors['email'] = $transLang['PASSWORD_USED']; endif;
endif;
endif;
if (!empty($_POST['newuser']) && empty($errors)):
$Users->addSAMLUser($timezone, $_POST['email'], $_POST['usertype']);
header('Location: ' . $_SERVER['PHP_SELF']);
endif;
if (!empty($_POST['editusercomplete'])): // EDIT USER
require_once("src/Misc/PasswordHash.php");
@@ -328,6 +342,7 @@ if (0 === $row_count): else: $page_count = (int)ceil($row_count / $StaticFunctio
</div>
<fieldset id="registration">
<div class="form-group">
<?php if (Registry::AUTHMETHOD == 'INTERNAL') { ?>
<div class="row">
<div class="col-sm">
<input type="text" class="form-control" id="firstname" name="firstname" placeholder="First Name" required />
@@ -336,14 +351,18 @@ if (0 === $row_count): else: $page_count = (int)ceil($row_count / $StaticFunctio
<input type="text" class="form-control" id="lastname" name="lastname" placeholder="Last Name" required />
</div>
</div>
<?php } ?>
<div class="row">
<?php if (Registry::AUTHMETHOD == 'INTERNAL') { ?>
<div class="col-sm">
<input type="text" class="form-control" id="username" name="username" placeholder="Username" required />
</div>
<?php } ?>
<div class="col-sm">
<input type="text" class="form-control" id="email" name="email" placeholder="Email" />
</div>
</div>
<?php if (Registry::AUTHMETHOD == 'INTERNAL') { ?>
<div class="row">
<div class="col-sm">
<input type="password" class="form-control" id="password" name="password" placeholder="Password" required />
@@ -352,6 +371,7 @@ if (0 === $row_count): else: $page_count = (int)ceil($row_count / $StaticFunctio
<input type="password" class="form-control" id="password_confirm" name="password_confirm" placeholder="Confirm Password" required />
</div>
</div>
<?php } ?>
<div class="row">
<div class="col-sm">
<select class="custom-select" id="usertype" aria-label="<?php echo $transLang['ACCESS_LEVEL']; ?>" name="usertype" required>