     }
 
     private func setAvatarWithInitials() {
-        let username = self.user?.username ?? "?"
+        guard let user = user, !user.isInvalidated else {
+            labelInitials?.text = "?"
+            backgroundColor = .black
+            return
+        }
 
+        let username = user.username ?? "?"
         var initials = ""
         var color: UInt = 0x000000
 


    var user: User? {
        didSet {
            if let user = user {
                if !user.isInvalidated {
                    updateAvatar()
                }
            } else {
                updateAvatar()
            }
        }
    }


    @IBOutlet weak var imageView: UIImageView!

    private func userAvatarURL() -> URL? {
        guard
            let user = user, !user.isInvalidated,
            let username = user.username,
            let auth = AuthManager.isAuthenticated(),
            let baseURL = auth.baseURL(),
            let encodedUsername = username.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)
        else {
            return nil
        }

        return URL(string: "\(baseURL)/avatar/\(encodedUsername)")
    }

