pub fn detect_state(&self) {
        // If we've checked the login status before, then we should assume the status
        // hasn't changed (we'd change this in a login/logout page)
        if let LoginState::Yes | LoginState::No = *self.state.get() {
            return;
        }

        // See the docs page on authentication to learn how to put something *secure*
        // here This example is NOT production-safe, and would result in
        // absolutely terrible security!!!

        // All we're doing in here is checking for the existence of a storage entry that
        // contains a username (any attacker could trivially fake this)
        // Note that this storage API may be inaccessible, which we completely ignore
        // here for simplicity
        let storage = web_sys::window().unwrap().local_storage().unwrap().unwrap();
        let auth_token = storage.get("username").unwrap(); // This is a `Result<Option<T>, E>`

        if let Some(username) = auth_token {
            self.username.set(username);
            self.state.set(LoginState::Yes);
        } else {
            self.username.set(String::new());
            self.state.set(LoginState::No)
        }
    }
Checks whether or not the user is logged in and modifies the internal
state accordingly. If this has already been run, it won't do anything
(aka. it will only run if it's `Server`)
examples/demos/auth/src/global_state.rs