Detect if the person running the project is logged in as the owner of the project

Hey @blairmacintyre, right now there’s no guaranteed way for a Glitch app to know that the user browsing the app is logged into Glitch at all. For something like this I’d suggest adding authentication of some kind to your app and relying on that.

One workaround you could use would be to manually set Glitch’s authentication token in your app (perhaps in localStorage) and then to call the Glitch API using that token to verify project membership. In the browser console for any project’s Editor window JSON.parse(localStorage.cachedUser).persistentToken will give you the currently-logged-in user’s identifier for calling the API. If you set that value in your app’s localStorage you could then use it to query the API to glean that user’s permissions to the current project.

The Glitch API is currently undocumented and unofficial, but another community member has documented it from publicly-available calls - you can take a look at that in Glitch API & Documentation. It is subject to change at any time, but please let us know if something you’re relying on breaks.

Hope this helps!