Skip to content

Commit

Permalink
Handle ajax call to resend an invitation correctly (#21013)
Browse files Browse the repository at this point in the history
* Handle ajax call to resend an invitatio correctly

* built vue files

* disallow sending password parameters as get

* update other password usages
  • Loading branch information
sgiehl committed Jul 27, 2023
1 parent 0473f3b commit b66db30
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 85 deletions.
5 changes: 5 additions & 0 deletions plugins/CoreHome/vue/dist/CoreHome.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/CoreHome/vue/dist/CoreHome.umd.min.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions plugins/CoreHome/vue/src/AjaxHelper/AjaxHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ export default class AjaxHelper<T = any> { // eslint-disable-line
if (Array.isArray(params)) {
helper.setBulkRequests(...(params as QueryParameters[]));
} else {
Object.keys(params).forEach((key) => {
if (/password/i.test(key)) {
throw new Error(`Password parameters are not allowed to be sent as GET parameter. Please send ${key} as POST parameter instead.`);
}
});

helper.addParams({
module: 'API',
format: options.format || 'json',
Expand Down
165 changes: 84 additions & 81 deletions plugins/UsersManager/vue/dist/UsersManager.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugins/UsersManager/vue/dist/UsersManager.umd.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions plugins/UsersManager/vue/src/UserEditForm/UserEditForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ export default defineComponent({
this.isResetting2FA = true;
return AjaxHelper.post({
method: 'TwoFactorAuth.resetTwoFactorAuth',
}, {
userLogin: this.theUser.login,
passwordConfirmation: password,
}).catch((e) => {
Expand Down
7 changes: 5 additions & 2 deletions plugins/UsersManager/vue/src/UsersManager/UsersManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,10 @@ export default defineComponent({
}
this.loading = true;
try {
const res = await AjaxHelper.fetch<{ value: string }>(
const res = await AjaxHelper.post<{ value: string }>(
{
method: 'UsersManager.generateInviteLink',
}, {
userLogin: this.userBeingEdited!.login,
passwordConfirmation: password,
},
Expand Down Expand Up @@ -431,10 +432,12 @@ ${translate('UsersManager_CopyDeniedHints', [`<br><span class="invite-link">${va
},
onResendInvite(password: string) {
if (password === '') return;
AjaxHelper.fetch<AjaxHelper>(
AjaxHelper.post<AjaxHelper>(
{
method: 'UsersManager.resendInvite',
userLogin: this.userBeingEdited!.login,
},
{
passwordConfirmation: password,
},
).then(() => {
Expand Down

0 comments on commit b66db30

Please sign in to comment.