templates: Update `invite_users_modal.hbs` for undefined variables.

Removes undefined `time_input` from  `invite_users_modal.hbs`.
The default input value for the expiration custom time limit is
not set until the "custom" option is selected from the dropdown.

Removes the undefined `csrf_input` from the same template. And
imports `csrf.ts` into `invite.js` to get the csrf token and
add it to the request data, which is the current pattern used
in other `/web/src` modules.
This commit is contained in:
Lauryn Menard 2023-04-08 13:16:25 +02:00 committed by Tim Abbott
parent ea2de5b0a4
commit af0b450817
2 changed files with 4 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import render_settings_dev_env_email_access from "../templates/settings/dev_env_
import * as channel from "./channel";
import * as common from "./common";
import {csrf_token} from "./csrf";
import * as dialog_widget from "./dialog_widget";
import * as gear_menu from "./gear_menu";
import {$t, $t_html} from "./i18n";
@ -50,7 +51,7 @@ function get_common_invitation_data() {
stream_ids.push(stream_id);
});
const data = {
csrfmiddlewaretoken: $('input[name="csrfmiddlewaretoken"]').attr("value"),
csrfmiddlewaretoken: csrf_token,
invite_as,
stream_ids: JSON.stringify(stream_ids),
invite_expires_in_minutes: expires_in,

View File

@ -1,4 +1,4 @@
<form id="invite-user-form">{{ csrf_input }}
<form id="invite-user-form">
{{#if development_environment}}
<div class="alert" id="dev_env_msg"></div>
{{/if}}
@ -28,7 +28,7 @@
<p id="expires_on"></p>
<div id="custom-invite-expiration-time" class="dependent-settings-block">
<label for="expires_in">{{t "Custom time" }}</label>
<input type="text" autocomplete="off" name="custom-expiration-time" id="custom-expiration-time-input" class="custom-expiration-time inline-block" value="{{time_input}}" maxlength="3"/>
<input type="text" autocomplete="off" name="custom-expiration-time" id="custom-expiration-time-input" class="custom-expiration-time inline-block" value="" maxlength="3"/>
<select class="custom-expiration-time bootstrap-focus-style" id="custom-expiration-time-unit">
{{#each time_choices}}
<option name="custom_time_choice" class="custom_time_choice" value="{{this}}">{{this}}</option>