Last active
August 27, 2022 18:17
-
-
Save jirawatee/407aac2436747f37af521834117b312f to your computer and use it in GitHub Desktop.
How to hack LIFF Login in external browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>LIFF - LINE Front-end Framework</title> | |
<style> | |
body { margin: 16px } | |
button, img { display: none; width: 40% } | |
button { padding: 16px } | |
</style> | |
</head> | |
<body> | |
<h1>Page 2</h1> | |
<img id="pictureUrl"> | |
<button id="btnLogIn" onclick="logIn()">Log In</button> | |
<button id="btnLogOut" onclick="logOut()">Log Out</button> | |
<script src="https://static.line-scdn.net/liff/edge/2/sdk.js"></script> | |
<script> | |
function logOut() { | |
liff.logout() | |
window.location.reload() | |
} | |
function logIn() { | |
liff.login({ redirectUri: window.location.href }) | |
} | |
async function getUserProfile() { | |
const profile = await liff.getProfile() | |
document.getElementById("pictureUrl").style.display = "block" | |
document.getElementById("pictureUrl").src = profile.pictureUrl | |
} | |
async function main() { | |
await liff.init({ liffId: "YOUR-LIFF-ID" }) | |
if (liff.isInClient()) { | |
getUserProfile() | |
} else { | |
if (liff.isLoggedIn()) { | |
getUserProfile() | |
document.getElementById("btnLogIn").style.display = "none" | |
document.getElementById("btnLogOut").style.display = "block" | |
} else { | |
document.getElementById("btnLogIn").style.display = "block" | |
document.getElementById("btnLogOut").style.display = "none" | |
} | |
} | |
} | |
main() | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment