diff options
author | David Baker <dave@matrix.org> | 2016-05-10 14:40:19 +0200 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2016-05-10 14:40:19 +0200 |
commit | 997db0464828c8e8eac7dfa055f4fcd25e89cd29 (patch) | |
tree | d10252566e9bc96a9bdf95bcd37e4db4ead6ab62 /synapse/storage/openid.py | |
parent | More consistent config naming (diff) | |
parent | Merge pull request #773 from matrix-org/erikj/get_domian_from_id (diff) | |
download | synapse-997db0464828c8e8eac7dfa055f4fcd25e89cd29.tar.xz |
Merge remote-tracking branch 'origin/develop' into dbkr/email_notifs
Diffstat (limited to 'synapse/storage/openid.py')
-rw-r--r-- | synapse/storage/openid.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/synapse/storage/openid.py b/synapse/storage/openid.py new file mode 100644 index 0000000000..5dabb607bd --- /dev/null +++ b/synapse/storage/openid.py @@ -0,0 +1,32 @@ +from ._base import SQLBaseStore + + +class OpenIdStore(SQLBaseStore): + def insert_open_id_token(self, token, ts_valid_until_ms, user_id): + return self._simple_insert( + table="open_id_tokens", + values={ + "token": token, + "ts_valid_until_ms": ts_valid_until_ms, + "user_id": user_id, + }, + desc="insert_open_id_token" + ) + + def get_user_id_for_open_id_token(self, token, ts_now_ms): + def get_user_id_for_token_txn(txn): + sql = ( + "SELECT user_id FROM open_id_tokens" + " WHERE token = ? AND ? <= ts_valid_until_ms" + ) + + txn.execute(sql, (token, ts_now_ms)) + + rows = txn.fetchall() + if not rows: + return None + else: + return rows[0][0] + return self.runInteraction( + "get_user_id_for_token", get_user_id_for_token_txn + ) |