mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Force logout on change own password
This commit is contained in:
@@ -18,6 +18,7 @@ export class UserEditDialogComponent
|
||||
implements OnInit
|
||||
{
|
||||
groups: PaperlessGroup[]
|
||||
passwordIsSet: boolean = false
|
||||
|
||||
constructor(
|
||||
service: UserService,
|
||||
@@ -76,4 +77,11 @@ export class UserEditDialogComponent
|
||||
(id) => this.groups.find((g) => g.id == id)?.permissions
|
||||
)
|
||||
}
|
||||
|
||||
save(): void {
|
||||
this.passwordIsSet =
|
||||
this.objectForm.get('password').value?.toString().replaceAll('*', '')
|
||||
.length > 0
|
||||
super.save()
|
||||
}
|
||||
}
|
||||
|
@@ -648,14 +648,26 @@ export class SettingsComponent
|
||||
modal.componentInstance.succeeded
|
||||
.pipe(takeUntil(this.unsubscribeNotifier))
|
||||
.subscribe({
|
||||
next: (newUser) => {
|
||||
this.toastService.showInfo(
|
||||
$localize`Saved user "${newUser.username}".`
|
||||
)
|
||||
this.usersService.listAll().subscribe((r) => {
|
||||
this.users = r.results
|
||||
this.initialize()
|
||||
})
|
||||
next: (newUser: PaperlessUser) => {
|
||||
if (
|
||||
newUser.id === this.settings.currentUser.id &&
|
||||
(modal.componentInstance as UserEditDialogComponent).passwordIsSet
|
||||
) {
|
||||
this.toastService.showInfo(
|
||||
$localize`Password has been changed, you will be logged out momentarily.`
|
||||
)
|
||||
setTimeout(() => {
|
||||
window.location.href = `${window.location.origin}/accounts/logout/?next=/accounts/login/`
|
||||
}, 2500)
|
||||
} else {
|
||||
this.toastService.showInfo(
|
||||
$localize`Saved user "${newUser.username}".`
|
||||
)
|
||||
this.usersService.listAll().subscribe((r) => {
|
||||
this.users = r.results
|
||||
this.initialize()
|
||||
})
|
||||
}
|
||||
},
|
||||
error: (e) => {
|
||||
this.toastService.showError(
|
||||
|
Reference in New Issue
Block a user