Browse Source

Extend user account deletion to users without security token

pull/8093/head
Thomas Kaul 7 days ago
parent
commit
a8fa33f98d
  1. 1
      apps/api/src/app/user/user.controller.ts
  2. 3
      apps/api/src/app/user/user.service.ts
  3. 18
      apps/client/src/app/components/user-account-settings/user-account-settings.component.ts
  4. 2
      apps/client/src/app/components/user-account-settings/user-account-settings.html

1
apps/api/src/app/user/user.controller.ts

@ -75,7 +75,6 @@ export class UserController {
public async deleteOwnUser(
@Body() data: DeleteOwnUserDto
): Promise<UserModel> {
// Only users of the anonymous provider have a security token
const user =
this.request.user.provider === 'ANONYMOUS'
? await this.validateAccessToken(data.accessToken, this.request.user.id)

3
apps/api/src/app/user/user.service.ts

@ -439,9 +439,8 @@ export class UserService {
currentPermissions.push(permissions.enableSubscriptionInterstitial);
}
// Users without a security token (e.g. Google) can close their user
// account themselves only within a period after the registration
if (
!hasRole(user, Role.DEMO) &&
user.provider !== 'ANONYMOUS' &&
isBefore(
new Date(),

18
apps/client/src/app/components/user-account-settings/user-account-settings.component.ts

@ -277,14 +277,20 @@ export class GfUserAccountSettingsComponent implements OnInit {
this.notificationService.confirm({
confirmFn: () => {
this.dataService
.deleteOwnUser({
accessToken: this.deleteOwnUserForm.controls.accessToken.value
})
.deleteOwnUser(
this.hasPermissionToUpdateOwnAccessToken
? {
accessToken: this.deleteOwnUserForm.controls.accessToken.value
}
: {}
)
.pipe(
catchError(() => {
this.notificationService.alert({
title: $localize`Oops! Incorrect Security Token.`
});
if (this.hasPermissionToUpdateOwnAccessToken) {
this.notificationService.alert({
title: $localize`Oops! Incorrect Security Token.`
});
}
return EMPTY;
}),

2
apps/client/src/app/components/user-account-settings/user-account-settings.html

@ -366,7 +366,7 @@
Close Account
</button>
</form>
} @else if (hasPermissionToDeleteOwnUser) {
} @else if (hasPermissionToDeleteOwnUser && !hasImpersonationId) {
<button
color="warn"
i18n

Loading…
Cancel
Save