mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: only allow CSV file to be uploaded for bulk invite
This commit is contained in:
@@ -6,6 +6,10 @@ export default Em.Component.extend(UploadMixin, {
|
|||||||
tagName: "span",
|
tagName: "span",
|
||||||
uploadUrl: "/invites/upload_csv",
|
uploadUrl: "/invites/upload_csv",
|
||||||
|
|
||||||
|
validateUploadedFilesOptions() {
|
||||||
|
return { csvOnly: true };
|
||||||
|
},
|
||||||
|
|
||||||
@computed("uploading")
|
@computed("uploading")
|
||||||
uploadButtonText(uploading) {
|
uploadButtonText(uploading) {
|
||||||
return uploading ? I18n.t("uploading") : I18n.t("user.invited.bulk_invite.text");
|
return uploading ? I18n.t("uploading") : I18n.t("user.invited.bulk_invite.text");
|
||||||
|
|||||||
@@ -192,6 +192,11 @@ export function validateUploadedFile(file, opts) {
|
|||||||
bootbox.alert(I18n.t('post.errors.upload_not_authorized', { authorized_extensions: authorizedImagesExtensions() }));
|
bootbox.alert(I18n.t('post.errors.upload_not_authorized', { authorized_extensions: authorizedImagesExtensions() }));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else if (opts["csvOnly"]) {
|
||||||
|
if (!(/\.csv$/i).test(name)) {
|
||||||
|
bootbox.alert(I18n.t('user.invited.bulk_invite.error'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!authorizesAllExtensions() && !isAuthorizedFile(name)) {
|
if (!authorizesAllExtensions() && !isAuthorizedFile(name)) {
|
||||||
bootbox.alert(I18n.t('post.errors.upload_not_authorized', { authorized_extensions: authorizedExtensions() }));
|
bootbox.alert(I18n.t('post.errors.upload_not_authorized', { authorized_extensions: authorizedExtensions() }));
|
||||||
|
|||||||
@@ -156,9 +156,9 @@ class InvitesController < ApplicationController
|
|||||||
|
|
||||||
Scheduler::Defer.later("Upload CSV") do
|
Scheduler::Defer.later("Upload CSV") do
|
||||||
begin
|
begin
|
||||||
data = if extension == ".csv"
|
data = if extension.downcase == ".csv"
|
||||||
path = Invite.create_csv(file, name)
|
path = Invite.create_csv(file, name)
|
||||||
Jobs.enqueue(:bulk_invite, filename: "#{name}.csv", current_user_id: current_user.id)
|
Jobs.enqueue(:bulk_invite, filename: "#{name}#{extension}", current_user_id: current_user.id)
|
||||||
{url: path}
|
{url: path}
|
||||||
else
|
else
|
||||||
failed_json.merge(errors: [I18n.t("bulk_invite.file_should_be_csv")])
|
failed_json.merge(errors: [I18n.t("bulk_invite.file_should_be_csv")])
|
||||||
|
|||||||
@@ -833,6 +833,7 @@ en:
|
|||||||
none: "You haven't invited anyone here yet. You can send individual invites, or invite a bunch of people at once by <a href='https://meta.discourse.org/t/send-bulk-invites/16468'>uploading a CSV file</a>."
|
none: "You haven't invited anyone here yet. You can send individual invites, or invite a bunch of people at once by <a href='https://meta.discourse.org/t/send-bulk-invites/16468'>uploading a CSV file</a>."
|
||||||
text: "Bulk Invite from File"
|
text: "Bulk Invite from File"
|
||||||
success: "File uploaded successfully, you will be notified via message when the process is complete."
|
success: "File uploaded successfully, you will be notified via message when the process is complete."
|
||||||
|
error: "Sorry, file should be of csv format."
|
||||||
|
|
||||||
password:
|
password:
|
||||||
title: "Password"
|
title: "Password"
|
||||||
|
|||||||
Reference in New Issue
Block a user