Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter <peter@innocraft.com>2022-08-29 05:39:21 +0300
committerPeter <peter@innocraft.com>2022-08-29 05:39:21 +0300
commit23afba2ae7693babe072e58ac82244b4b939a538 (patch)
tree370a4b126a82797b9b9d7172d8a855c65d967c11 /plugins/UsersManager
parentce2b9761025b9a6c756beab8995a954fc18dbdeb (diff)
update invite token links
update invite token links
Diffstat (limited to 'plugins/UsersManager')
-rw-r--r--plugins/UsersManager/API.php14
-rw-r--r--plugins/UsersManager/UsersManager.php2
-rw-r--r--plugins/UsersManager/lang/en.json6
-rw-r--r--plugins/UsersManager/vue/src/UserEditForm/UserEditForm.vue11
-rw-r--r--plugins/UsersManager/vue/src/UsersManager/UsersManager.vue57
5 files changed, 60 insertions, 30 deletions
diff --git a/plugins/UsersManager/API.php b/plugins/UsersManager/API.php
index 5d24aa847e..53c293894d 100644
--- a/plugins/UsersManager/API.php
+++ b/plugins/UsersManager/API.php
@@ -28,8 +28,10 @@ use Piwik\Plugins\Login\PasswordVerifier;
use Piwik\Plugins\UsersManager\Emails\UserInfoChangedEmail;
use Piwik\Plugins\UsersManager\Repository\UserRepository;
use Piwik\Plugins\UsersManager\Validators\Email;
+use Piwik\SettingsPiwik;
use Piwik\Site;
use Piwik\Tracker\Cache;
+use Piwik\Url;
use Piwik\Validators\BaseValidator;
/**
@@ -793,7 +795,11 @@ class API extends \Piwik\Plugin\API
* @param string $email The new user's e-mail.
*/
Piwik::postEvent('UsersManager.inviteUser.end', [$userLogin, $email]);
- return $token;
+ return SettingsPiwik::getPiwikUrl() . 'index.php?' . Url::getQueryStringFromParameters([
+ 'module' => 'Login',
+ 'action' => 'acceptInvitation',
+ 'token' => $token,
+ ]);
}
/**
@@ -1554,6 +1560,10 @@ class API extends \Piwik\Plugin\API
*/
Piwik::postEvent('UsersManager.inviteUser.resendInvite', [$userLogin, $user['email']]);
- return $token;
+ return SettingsPiwik::getPiwikUrl() . 'index.php?' . Url::getQueryStringFromParameters([
+ 'module' => 'Login',
+ 'action' => 'acceptInvitation',
+ 'token' => $token,
+ ]);
}
}
diff --git a/plugins/UsersManager/UsersManager.php b/plugins/UsersManager/UsersManager.php
index 5f80f87421..96da8e488c 100644
--- a/plugins/UsersManager/UsersManager.php
+++ b/plugins/UsersManager/UsersManager.php
@@ -345,5 +345,7 @@ class UsersManager extends \Piwik\Plugin
$translationKeys[] = 'UsersManager_DeleteSuccess';
$translationKeys[] = 'UsersManager_DeleteNotSuccessful';
$translationKeys[] = 'UsersManager_InviteConfirm';
+ $translationKeys[] = 'UsersManager_CopyLink';
+ $translationKeys[] = 'UsersManager_Copied';
}
}
diff --git a/plugins/UsersManager/lang/en.json b/plugins/UsersManager/lang/en.json
index ad6bf95dbc..9293a443e2 100644
--- a/plugins/UsersManager/lang/en.json
+++ b/plugins/UsersManager/lang/en.json
@@ -198,11 +198,13 @@
"Active": "Active",
"Expired": "Invite expired",
"Decline": "Invite declined",
- "ResendInviteSuccess": "Success! The invite has been resent to user %s.",
+ "ResendInviteSuccess": "Success! The invite has been resent to user.",
"InviteSuccess": "Success! The invite has been sent.",
"InviteDayLeft": "Expires in %s days",
"FilterByStatus": "Filter by status",
"ExceptionResendInviteDenied": "Resending an invite is only allowed to the user who invited %s or any super user.",
- "ExpiredInviteAutomaticallyRemoved": "Expired invites will be automatically deleted after %1$s days."
+ "ExpiredInviteAutomaticallyRemoved": "Expired invites will be automatically deleted after %1$s days.",
+ "CopyLink": "Copy Link",
+ "Copied": "Copied"
}
}
diff --git a/plugins/UsersManager/vue/src/UserEditForm/UserEditForm.vue b/plugins/UsersManager/vue/src/UserEditForm/UserEditForm.vue
index 245f393233..15d1e9417f 100644
--- a/plugins/UsersManager/vue/src/UserEditForm/UserEditForm.vue
+++ b/plugins/UsersManager/vue/src/UserEditForm/UserEditForm.vue
@@ -420,15 +420,15 @@ export default defineComponent({
).catch((e) => {
this.isSavingUserInfo = false;
throw e;
- }).then(() => {
+ }).then((r) => {
this.firstSiteAccess = null;
this.isSavingUserInfo = false;
this.isUserModified = true;
this.theUser.invite_status = 'pending';
this.resetPasswordVar();
- this.showUserCreatedNotification();
this.$emit('updated', { user: readonly(this.theUser) });
+ this.$emit('show-notification', r.value);
});
},
resetPasswordVar() {
@@ -444,13 +444,6 @@ export default defineComponent({
type: 'toast',
});
},
- showUserCreatedNotification() {
- NotificationsStore.show({
- message: translate('UsersManager_InviteSuccess'),
- context: 'success',
- type: 'toast',
- });
- },
reset2FA(password: string) {
this.isResetting2FA = true;
return AjaxHelper.post({
diff --git a/plugins/UsersManager/vue/src/UsersManager/UsersManager.vue b/plugins/UsersManager/vue/src/UsersManager/UsersManager.vue
index 76f6c1e90c..66758dd3dd 100644
--- a/plugins/UsersManager/vue/src/UsersManager/UsersManager.vue
+++ b/plugins/UsersManager/vue/src/UsersManager/UsersManager.vue
@@ -6,6 +6,19 @@
<template>
<div class="usersManager" v-tooltips>
+ <div class="notification system notification-success"
+ v-if="showNotification">
+ <div>
+ <Notification
+ context="success"
+ >
+ {{ translate('UsersManager_ResendInviteSuccess') }}
+ <a href="#" v-if="!copied" @click="copyToClipboard(token)">
+ {{ translate('UsersManager_CopyLink') }}</a>
+ <span v-if="copied"> {{ translate('UsersManager_Copied')}}</span>
+ </Notification>
+ </div>
+ </div>
<div v-show="!isEditing">
<div v-content-intro>
<h2>
@@ -75,6 +88,7 @@
:initial-site-id="initialSiteId"
:initial-site-name="initialSiteName"
@updated="userBeingEdited = $event.user"
+ @show-notification="showInviteNotification"
/>
</div>
<div class="add-existing-user-modal modal" ref="addExistingUserModal">
@@ -109,7 +123,7 @@
<script lang="ts">
/* eslint-disable newline-per-chained-call */
-import {defineComponent} from 'vue';
+import { defineComponent } from 'vue';
import {
ContentIntro,
EnrichedHeadline,
@@ -120,7 +134,7 @@ import {
translate,
NotificationsStore,
} from 'CoreHome';
-import {Field} from 'CorePluginsAdmin';
+import { Field } from 'CorePluginsAdmin';
import PagedUsersList from '../PagedUsersList/PagedUsersList.vue';
import UserEditForm from '../UserEditForm/UserEditForm.vue';
import User from '../User';
@@ -136,11 +150,13 @@ interface UsersManagerState {
isLoadingUsers: boolean;
addNewUserLoginEmail: string;
token: string;
+ showNotification: boolean;
+ copied: boolean;
}
const NUM_USERS_PER_PAGE = 20;
-const {$} = window;
+const { $ } = window;
export default defineComponent({
props: {
@@ -193,7 +209,9 @@ export default defineComponent({
filter_status: '',
idSite: this.initialSiteId,
},
- token:null,
+ copied: false,
+ showNotification: false,
+ token: null,
isLoadingUsers: false,
userBeingEdited: null,
addNewUserLoginEmail: '',
@@ -203,6 +221,9 @@ export default defineComponent({
this.fetchUsers();
},
watch: {
+ showNotification(value) {
+ if (!value) this.copied = false;
+ },
limit() {
this.fetchUsers();
},
@@ -220,7 +241,7 @@ export default defineComponent({
}
},
showAddExistingUserModal() {
- $(this.$refs.addExistingUserModal as HTMLElement).modal({dismissible: false}).modal('open');
+ $(this.$refs.addExistingUserModal as HTMLElement).modal({ dismissible: false }).modal('open');
},
onChangeUserRole(users: User[] | string, role: string) {
this.isLoadingUsers = true;
@@ -253,7 +274,7 @@ export default defineComponent({
}));
}
- return AjaxHelper.fetch(requests, {createErrorNotification: true});
+ return AjaxHelper.fetch(requests, { createErrorNotification: true });
}).catch(() => {
// ignore (errors will still be displayed to the user)
}).then(() => this.fetchUsers());
@@ -282,7 +303,7 @@ export default defineComponent({
userLogin: login,
passwordConfirmation: password,
}));
- return AjaxHelper.fetch(requests, {createErrorNotification: true});
+ return AjaxHelper.fetch(requests, { createErrorNotification: true });
}).then(() => {
NotificationsStore.scrollToNotification(NotificationsStore.show({
id: 'removeUserSuccess',
@@ -307,6 +328,10 @@ export default defineComponent({
this.fetchUsers();
});
},
+ copyToClipboard(value) {
+ navigator.clipboard.writeText(value);
+ this.copied = true;
+ },
onResendInvite(user: User) {
AjaxHelper.fetch<AjaxHelper>(
{
@@ -315,16 +340,13 @@ export default defineComponent({
},
).then((r) => {
this.fetchUsers();
- navigator.clipboard.writeText(r.value);
- const id = NotificationsStore.show({
- message: translate('UsersManager_ResendInviteSuccess', user.login) + ' <a href="#" onclick=\'navigator.clipboard.writeText(this.token)\'>Copy Link</a>',
- id: 'resendinvite',
- context: 'success',
- type: 'transient',
- });
- NotificationsStore.scrollToNotification(id);
+ this.showInviteNotification(r.value);
});
},
+ showInviteNotification(token) {
+ this.showNotification = true;
+ this.token = token;
+ },
fetchUsers() {
this.isLoadingUsers = true;
return AjaxHelper.fetch<AjaxHelper>(
@@ -332,7 +354,7 @@ export default defineComponent({
...this.searchParams,
method: 'UsersManager.getUsersPlusRole',
},
- {returnResponseObject: true},
+ { returnResponseObject: true },
).then((helper) => {
const result = helper.getRequestHandle()!;
@@ -379,7 +401,8 @@ export default defineComponent({
});
},
onAddNewUser() {
- const parameters = {isAllowed: true};
+ this.showNotification = false;
+ const parameters = { isAllowed: true };
Matomo.postEvent('UsersManager.initAddUser', parameters);
if (parameters && !parameters.isAllowed) {
return;