Agent Wranglers

MOB-25Recommended

Wipe local data at sign-out

Signing out removes the person's tokens, local database, caches and files from the phone. The next person to sign in sees none of it.

How to do it

Phones are shared, sold and handed in for repair. Keep all of a person's files under one folder or database, so sign-out deletes one place. Clear image and HTTP caches too. Tell the server, so it ends the session and unlinks push, as unlink push from the account at sign-out says. Warn first when unsynced changes would be lost.

Examples

Plain text example

func signOut() async {
    try? await api.post("/sessions/current/end")
    SecItemDelete([kSecClass as String: kSecClassGenericPassword] as CFDictionary)
    try? FileManager.default.removeItem(at: userDataDirectory)
    URLCache.shared.removeAllCachedResponses()
}

Kotlin example

suspend fun signOut() {
    runCatching { api.post("/sessions/current/end") }
    context.deleteDatabase("user.db")
    File(context.filesDir, "user").deleteRecursively()
    context.cacheDir.deleteRecursively()
}

How to check

Sign in as one test user, load data, sign out and sign in as a second user. No screen, search or cache shows the first user's data, and the first user's folder is gone.

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/mobile-apps/data-on-the-device/wipe-on-sign-out">Agent Wranglers mobile apps playbook</a>. In code you write, add a comment next to it with the same link.