File tree Expand file tree Collapse file tree
src/app/features/admin/components/admin-dashboard Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -154,8 +154,8 @@ <h2>Admin Dashboard</h2>
154154 < p-inputSwitch
155155 [ngModel] ="user.isActive "
156156 (ngModelChange) ="onActiveStatusChange(user, $event) "
157- [disabled] ="isStatusUpdating(user.id) || isLoading "
158- [pTooltip] ="isStatusUpdating(user.id) ? 'Updating user status...' : '' "
157+ [disabled] ="isStatusUpdating(user.id) || isLoading || isCurrentLoggedInAdmin(user) "
158+ [pTooltip] ="isCurrentLoggedInAdmin(user) ? 'You cannot deactivate your own administrator account.' : ( isStatusUpdating(user.id) ? 'Updating user status...' : '') "
159159 tooltipPosition ="top ">
160160 </ p-inputSwitch >
161161 </ td >
Original file line number Diff line number Diff line change @@ -103,6 +103,10 @@ export class AdminDashboardComponent implements OnInit {
103103 return this . authService . hasRole ( AppRole . Administrator ) ;
104104 }
105105
106+ get currentUserId ( ) : string | null {
107+ return this . authService . currentUserId ( ) ;
108+ }
109+
106110 ngOnInit ( ) : void {
107111 this . rows = this . preferencesService . preferences ( ) . defaultTablePageSize ;
108112 this . loadUsers ( ) ;
@@ -185,11 +189,19 @@ export class AdminDashboardComponent implements OnInit {
185189 return this . updatingUserIds . has ( userId ) ;
186190 }
187191
192+ isCurrentLoggedInAdmin ( user : UserSummaryDto ) : boolean {
193+ return user . id === this . currentUserId && user . roles . includes ( AppRole . Administrator ) ;
194+ }
195+
188196 onActiveStatusChange ( user : UserSummaryDto , isActive : boolean ) : void {
189197 if ( user . isActive === isActive || this . isStatusUpdating ( user . id ) ) {
190198 return ;
191199 }
192200
201+ if ( this . isCurrentLoggedInAdmin ( user ) && ! isActive ) {
202+ return ;
203+ }
204+
193205 const previousStatus = user . isActive ;
194206 user . isActive = isActive ;
195207
You can’t perform that action at this time.
0 commit comments