Skip to content

Instantly share code, notes, and snippets.

@dun4n
Last active January 4, 2016 04:39
Show Gist options
  • Save dun4n/8570121 to your computer and use it in GitHub Desktop.
Save dun4n/8570121 to your computer and use it in GitHub Desktop.
Use CSP to detect if a user is logged in to Github.com.
<!DOCTYPE html>
<html>
<head>
<meta content="img-src https://github.com/login;" http-equiv="Content-Security-Policy">
<script type="text/javascript">
var islogged = true
window.onload = function() { console.log("Logged in to Github : " + islogged) }
</script>
<img src="https://github.com/login" onerror="islogged = false" />
</head>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment