add new endpoints for app v2 #116

Merged
edenhaus merged 17 commits from ecovacs-home into master 2021-06-05 15:06:19 +02:00
2 changed files with 16 additions and 0 deletions
Showing only changes of commit a5359ac4c6 - Show all commits

View file

@ -265,6 +265,7 @@ async def start():
async def maintenance():
revoke_expired_tokens()
revoke_expired_oauths()
async def shutdown():

View file

@ -203,6 +203,21 @@ def user_revoke_authcode(userid, token, authcode):
)
def revoke_expired_oauths():
opendb = db_get()
with opendb:
table = opendb.table("oauth")
entries = table.all()
for i in entries:
oauth = OAuth(**i)
if datetime.now() >= datetime.fromisoformat(oauth.expire_at):
bumperlog.debug(
"Removing oauth {} due to expiration".format(oauth.access_token)
)
table.remove(doc_ids=[i.doc_id])
def user_revoke_expired_oauths(userid):
opendb = db_get()
with opendb: