-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved UserProfile to mojang.account._structures and UserSession to mo…
…jang.account._session
- Loading branch information
Showing
12 changed files
with
192 additions
and
83 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .base import status, get_uuid, get_uuids, names | ||
from .base import status, get_uuid, get_uuids, names, user | ||
from ._session import connect |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,36 @@ | ||
import requests | ||
|
||
from ._urls import URLs | ||
from ...exceptions import * | ||
from .._auth import BearerAuth | ||
from .._structures import ChallengeInfo | ||
from ._urls import URLs | ||
|
||
# TODO: Handle errors and exception | ||
|
||
def check_ip(access_token: str): | ||
response = requests.get(URLs.verify_ip(), auth=BearerAuth(access_token)) | ||
try: | ||
handle_response(response, PayloadError, Unauthorized, IPNotSecured) | ||
except IPNotSecured: | ||
return False | ||
else: | ||
return True | ||
|
||
def get_challenges(access_token: str): | ||
response = requests.get(URLs.get_challenges(), auth=BearerAuth(access_token)) | ||
data = handle_response(response, PayloadError, Unauthorized) | ||
|
||
_challenges = [] | ||
for item in response.json(): | ||
for item in data: | ||
_challenges.append(ChallengeInfo(id=item['answer']['id'], challenge=item['question']['question'])) | ||
|
||
return _challenges | ||
|
||
def verify_ip(access_token: str, answers: list): | ||
answers = map(lambda a: {'id': a[0], 'answer': a[1]}, answers) | ||
response = requests.post(URLs.verify_ip(), auth=BearerAuth(access_token), json=answers) | ||
try: | ||
handle_response(response, PayloadError, Unauthorized, IPVerificationError) | ||
except IPVerificationError: | ||
return False | ||
else: | ||
return True |
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.