Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Updating Incoming Integration Post As Field Not Allowed #6903

Merged
merged 1 commit into from
May 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
<div class="input-line double-col">
<label>{{_ "Post_as"}}</label>
<div>
{{#if data.token}}
<input type="text" name="username" value="{{data.username}}" readonly="readonly" />
{{else}}
<input type="text" name="username" value="{{data.username}}" />
{{/if}}
<input type="text" name="username" value="{{data.username}}" />
<div class="settings-description secondary-font-color">{{_ "Choose_the_username_that_this_integration_will_post_as"}}</div>
<div class="settings-description secondary-font-color">{{_ "Should_exists_a_user_with_this_username"}}</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ Template.integrationsIncoming.events({
const integration = {
enabled: enabled === '1',
channel,
username,
alias: alias !== '' ? alias : undefined,
emoji: emoji !== '' ? emoji : undefined,
avatar: avatar !== '' ? avatar : undefined,
Expand All @@ -240,8 +241,6 @@ Template.integrationsIncoming.events({
toastr.success(TAPi18n.__('Integration_updated'));
});
} else {
integration.username = username;

Meteor.call('addIncomingIntegration', integration, (err, data) => {
if (err) {
return handleError(err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ Meteor.methods({
}

const user = RocketChat.models.Users.findOne({ username: currentIntegration.username });

if (!user || !user._id) {
throw new Meteor.Error('error-invalid-post-as-user', 'Invalid Post As User', { method: 'updateIncomingIntegration' });
}

RocketChat.models.Roles.addUserRoles(user._id, 'bot');

RocketChat.models.Integrations.update(integrationId, {
Expand Down