Last active
August 29, 2015 14:28
-
-
Save Techcable/7dd992e1bd073b2e728a to your computer and use it in GitHub Desktop.
Session Invalidate
This file contains hidden or 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
| if [ $# -lt 2 ]; | |
| then | |
| echo "Usage: {username} {password}" | |
| echo "If your account is migrated, use your email as your username" | |
| exit 1; | |
| fi; | |
| USERNAME=$1 | |
| PASSWORD=$2 | |
| REQUEST_DATA="{\"username\": \"$USERNAME\", \"password\": \"$PASSWORD\"}" | |
| RESPONSE=$(curl -H "Content-Type: application/json" -X POST -d "$REQUEST_DATA" "https://authserver.mojang.com/signout" > /dev/null) | |
| if [ "$RESPONSE" != "" ]; # Check if the line is only whitespace | |
| then | |
| WHITESPACE=false | |
| else | |
| WHITESPACE=true; | |
| fi; | |
| echo $RESPONSE | grep "migrated" | |
| MIGRATED=$? | |
| if [ $WHITESPACE ]; | |
| then | |
| MIGRATED=false | |
| fi; | |
| echo $RESPONSE | grep "ForbiddenOperationException" | |
| INVALID_ACCOUNT=$? | |
| if [ $WHITESPACE ]; | |
| then | |
| INVALID_ACCOUNT=false | |
| fi; | |
| if [ $MIGRATED == 0 ]; | |
| then | |
| echo "Account Migrated" | |
| echo "Please use your email" | |
| exit 2; | |
| elif [ $INVALID_ACCOUNT == 0 ]; | |
| then | |
| echo "Invalid username or password"; | |
| exit 3; | |
| fi; | |
| if [ ! $WHITESPACE ]; | |
| then | |
| echo "Unknown error: $RESPONSE" | |
| exit 4; | |
| else | |
| echo "Success" | |
| exit 0; | |
| fi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment