@@ -137,6 +137,7 @@ export default class ActivityWatcher extends Service {
137
137
@service declare eventsService : EventsService ;
138
138
@service declare toast : ToastService ;
139
139
@service declare intl : IntlService ;
140
+ @service declare session : any ;
140
141
141
142
private declare _observer : Observable < ResourceEvent > | null ;
142
143
@@ -147,7 +148,7 @@ export default class ActivityWatcher extends Service {
147
148
148
149
this . _observer = this . eventsService . watch ( prefixPath ( '/notification' ) ) ;
149
150
this . _observer . subscribe ( ( evt : NotificationEvent ) => {
150
- this . _processEvent ( evt ) ;
151
+ this . processEvent ( evt ) ;
151
152
} ) ;
152
153
}
153
154
@@ -160,8 +161,12 @@ export default class ActivityWatcher extends Service {
160
161
this . _observer = null ;
161
162
}
162
163
163
- private _processEvent ( evt : NotificationEvent ) : void {
164
- const notif = this . _buildNotification ( evt ) ;
164
+ private processEvent ( evt : NotificationEvent ) : void {
165
+ if ( evt . payload . notification_type === 'token_destroyed' ) {
166
+ this . checkIfUserNeedsToBeDisconnected ( evt ) ;
167
+ return ;
168
+ }
169
+ const notif = this . buildNotification ( evt ) ;
165
170
166
171
if ( ! notif ) {
167
172
return ;
@@ -182,7 +187,14 @@ export default class ActivityWatcher extends Service {
182
187
}
183
188
}
184
189
185
- private _buildNotification ( evt : NotificationEvent ) : RenderedNotification | null {
190
+ private checkIfUserNeedsToBeDisconnected ( event : NotificationEvent ) : void {
191
+ if ( this . session . data . authenticated . access_token === event . payload . data . access_token ) {
192
+ this . session . tooManyConnections = true ;
193
+ this . session . invalidate ( ) ;
194
+ }
195
+ }
196
+
197
+ private buildNotification ( evt : NotificationEvent ) : RenderedNotification | null {
186
198
const renderer = renderersByNotificationType [ evt . payload . notification_type ] ;
187
199
188
200
if ( ! renderer ) {
0 commit comments