mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 07:44:35 +02:00
#13344 no enable create tokens when date is older than today
This commit is contained in:
parent
346292fb54
commit
06e7740234
@ -77,6 +77,7 @@ if ($create_token === true || $update_token === true) {
|
|||||||
$expirationDate = get_parameter('date-expiration', null);
|
$expirationDate = get_parameter('date-expiration', null);
|
||||||
$expirationTime = get_parameter('time-expiration', null);
|
$expirationTime = get_parameter('time-expiration', null);
|
||||||
$validity = null;
|
$validity = null;
|
||||||
|
$error_date = false;
|
||||||
if (empty($expirationDate) === false && $expirationDate >= date('Y-m-d')) {
|
if (empty($expirationDate) === false && $expirationDate >= date('Y-m-d')) {
|
||||||
$validity = $expirationDate;
|
$validity = $expirationDate;
|
||||||
if (empty($expirationTime) === false && $expirationTime > date('H:i:s')) {
|
if (empty($expirationTime) === false && $expirationTime > date('H:i:s')) {
|
||||||
@ -84,6 +85,8 @@ if ($create_token === true || $update_token === true) {
|
|||||||
} else {
|
} else {
|
||||||
$validity .= ' 23:59:59';
|
$validity .= ' 23:59:59';
|
||||||
}
|
}
|
||||||
|
} else if ($expirationDate < date('Y-m-d')) {
|
||||||
|
$error_date = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$values = [
|
$values = [
|
||||||
@ -95,16 +98,22 @@ if ($create_token === true || $update_token === true) {
|
|||||||
// Create token.
|
// Create token.
|
||||||
if ($create_token === true) {
|
if ($create_token === true) {
|
||||||
try {
|
try {
|
||||||
$token = create_user_token($values);
|
if ($error_date === false) {
|
||||||
$smgInfo = __('This code will appear only once, please keep it in a safe place');
|
$token = create_user_token($values);
|
||||||
$smgInfo .= '.</br>';
|
$smgInfo = __('This code will appear only once, please keep it in a safe place');
|
||||||
$smgInfo .= __('If you lose the code, you will only able to delete it and create a new one');
|
$smgInfo .= '.</br>';
|
||||||
$smgInfo .= '.</br></br>';
|
$smgInfo .= __('If you lose the code, you will only able to delete it and create a new one');
|
||||||
$smgInfo .= '<i>';
|
$smgInfo .= '.</br></br>';
|
||||||
$smgInfo .= $token['token'];
|
$smgInfo .= '<i>';
|
||||||
$smgInfo .= '</i>';
|
$smgInfo .= $token['token'];
|
||||||
$tokenMsg = ui_print_info_message($smgInfo, '', true);
|
$smgInfo .= '</i>';
|
||||||
ui_print_success_message(__('Successfully created'));
|
$tokenMsg = ui_print_info_message($smgInfo, '', true);
|
||||||
|
ui_print_success_message(__('Successfully created'));
|
||||||
|
} else {
|
||||||
|
ui_print_error_message(
|
||||||
|
__('Date expiration must be bigger than today')
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
ui_print_error_message(
|
ui_print_error_message(
|
||||||
__('There was a problem creating this token, %s', $e->getMessage())
|
__('There was a problem creating this token, %s', $e->getMessage())
|
||||||
@ -115,8 +124,14 @@ if ($create_token === true || $update_token === true) {
|
|||||||
// Update token.
|
// Update token.
|
||||||
if ($update_token === true) {
|
if ($update_token === true) {
|
||||||
try {
|
try {
|
||||||
$token = update_user_token($id_token, $values);
|
if ($error_date === false) {
|
||||||
ui_print_success_message(__('Successfully updated'));
|
$token = update_user_token($id_token, $values);
|
||||||
|
ui_print_success_message(__('Successfully updated'));
|
||||||
|
} else {
|
||||||
|
echo ui_print_error_message(
|
||||||
|
__('Date expiration must be bigger than today')
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
ui_print_error_message(
|
ui_print_error_message(
|
||||||
__('There was a problem updating this token, %s', $e->getMessage())
|
__('There was a problem updating this token, %s', $e->getMessage())
|
||||||
|
@ -436,7 +436,7 @@ function ui_print_message($message, $class='', $attributes='', $return=false, $t
|
|||||||
$_SESSION['info_box_count']++;
|
$_SESSION['info_box_count']++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$position = (20 + ((int) $_SESSION['info_box_count'] * 100));
|
$position = (20 + (int) $_SESSION['info_box_count']);
|
||||||
|
|
||||||
$output = html_print_div(
|
$output = html_print_div(
|
||||||
[
|
[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user