From af0b4508174c840be2c8b5933f455ed2176bbe1a Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Sat, 8 Apr 2023 13:16:25 +0200 Subject: [PATCH] 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. --- web/src/invite.js | 3 ++- web/templates/invite_user_modal.hbs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web/src/invite.js b/web/src/invite.js index 6e3d07f47c..ca14129686 100644 --- a/web/src/invite.js +++ b/web/src/invite.js @@ -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, diff --git a/web/templates/invite_user_modal.hbs b/web/templates/invite_user_modal.hbs index 39a3c169ec..3e24f51cf1 100644 --- a/web/templates/invite_user_modal.hbs +++ b/web/templates/invite_user_modal.hbs @@ -1,4 +1,4 @@ -
{{ csrf_input }} + {{#if development_environment}}
{{/if}} @@ -28,7 +28,7 @@

- +