Skip to content

Commit

Permalink
Add more methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Lee authored and Joel Lee committed Jan 25, 2021
1 parent dda60f3 commit eff88f3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
44 changes: 21 additions & 23 deletions gotrue/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import urllib
import json

HTTPRegexp = "/^http:\/\//"
HTTPRegexp = "/^http://"
defaultApiURL = "/.netlify/identity"


Expand All @@ -27,37 +27,32 @@ def settings(self):
r = requests.get(f"{self.BASE_URL}/settings")
return r

def sign_up(credentials):
data = json.dumps({
"email": "[email protected]",
"password": "yadayada"
})
requests.post(f"{self.BASE_URL}/signup", data)
def sign_up(credentials: dict):
requests.post(f"{self.BASE_URL}/signup", credentials)

def login():
pass

def login_external_url(provider):
pass

def confirm(token, remember):
pass
def logout(jwt: str):
# TODO: Validate how to send jwt
requests.post(f"{self.BASE_URL}/logout", jwt)

def request_password_recovery(email):
def confirm(self, token, remember):
pass

def recover(token, remember):
def recover(self, email: str):
""" Send a recovery email """
pass

def accept_invite(token, password, remember):
pass
data = json.dumps({"email": email})
return requests.post(f"{self.BASE_URL}/recover", data)

def acceptInviteUrl(provider, token):
def accept_invite(self, token, password, remember):
pass

def get_user():
pass
requests.get(f"{self.BASE_URL}/user", jwt)

def update_user():
pass
Expand All @@ -74,15 +69,18 @@ def send_magic_link(self, email: str):
data = json.dumps({"email": email})
return requests.post(f"{self.BASE_URL}/magiclink", data=data)

def invite(self, invitation):
"""Invite a new user to join"""
return requests.post(f"{self.BASE_URL}/invite", invitation)

def grant_token(type, payload):
payload = json.dumps({
"email": "[email protected]",
"password": "yadayada"
})
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
requests.post(
"https://distracted-elion-6bf6a2.netlify.app/.netlify/identity/verify",
data=json.dumps({
"type": "signup",
"token": "tokenthing"
}))
requests.post(f"{self.BASE_URL}/verify",
data=json.dumps({
"type": "signup",
"token": "tokenthing"
}))
11 changes: 8 additions & 3 deletions tests/test_gotrue.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ def test_signup(client):
pass

def test_login(client):
assert 1
pass

def test_verify(client):
assert 1
pass

def test_logout(self):
pass


def test_send_magic_link(client):
res = client.send_magic_link("[email protected]")
res = client.send_magic_link("[email protected]")
assert (res.status_code == 200 or res.status_code == 429)


def test_recover_email(client):
res = client.recover("[email protected]")
assert (res.status_code == 200 or res.status_code == 429)

0 comments on commit eff88f3

Please sign in to comment.