forked from spacebar/SplatNet-Backend
add limited db support in regards to the remember me button
This commit is contained in:
parent
feab2abe15
commit
b32b40db49
5 changed files with 119 additions and 30 deletions
|
|
@ -1,7 +1,18 @@
|
|||
import requests
|
||||
import base64
|
||||
from argon2 import PasswordHasher
|
||||
|
||||
API_URL = "https://account.spfn.net/api/v2"
|
||||
ph = PasswordHasher()
|
||||
|
||||
def hash_password(password: str):
|
||||
return ph.hash(password)
|
||||
|
||||
def verify_password(hashed: str, password: str):
|
||||
try:
|
||||
return ph.verify(hashed, password)
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def get_token(username, password):
|
||||
creds = f"{username} {password}"
|
||||
|
|
@ -13,7 +24,7 @@ def get_token(username, password):
|
|||
}
|
||||
|
||||
response = requests.get(f"{API_URL}/oauth2/generate_token", headers=headers, timeout=10)
|
||||
return response.json().get("token") if response.ok else None
|
||||
return response.json() if response.ok else None
|
||||
|
||||
def get_profile(token):
|
||||
headers = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue