diff options
author | Mark Haines <mark.haines@matrix.org> | 2016-05-16 12:59:41 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2016-05-16 12:59:41 +0100 |
commit | dd95eb4cb5f1519bfd328249f97f8731c4a11b64 (patch) | |
tree | 96220dc54d2d6d0b36999c5c01db8d5f5b13b851 /synapse/handlers/auth.py | |
parent | add a url_preview_ip_range_whitelist config param so we can whitelist the mat... (diff) | |
parent | fix logo (diff) | |
download | synapse-dd95eb4cb5f1519bfd328249f97f8731c4a11b64.tar.xz |
Merge branch 'develop' into matthew/preview_url_ip_whitelist
Diffstat (limited to 'synapse/handlers/auth.py')
-rw-r--r-- | synapse/handlers/auth.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/synapse/handlers/auth.py b/synapse/handlers/auth.py index 61fe56032a..68d0d78fc6 100644 --- a/synapse/handlers/auth.py +++ b/synapse/handlers/auth.py @@ -521,11 +521,11 @@ class AuthHandler(BaseHandler): )) return m.serialize() - def generate_short_term_login_token(self, user_id): + def generate_short_term_login_token(self, user_id, duration_in_ms=(2 * 60 * 1000)): macaroon = self._generate_base_macaroon(user_id) macaroon.add_first_party_caveat("type = login") now = self.hs.get_clock().time_msec() - expiry = now + (2 * 60 * 1000) + expiry = now + duration_in_ms macaroon.add_first_party_caveat("time < %d" % (expiry,)) return macaroon.serialize() @@ -615,4 +615,7 @@ class AuthHandler(BaseHandler): Returns: Whether self.hash(password) == stored_hash (bool). """ - return bcrypt.hashpw(password, stored_hash) == stored_hash + if stored_hash: + return bcrypt.hashpw(password, stored_hash) == stored_hash + else: + return False |