diff options
author | Donald Stufft <donald@stufft.io> | 2013-07-21 02:08:59 -0400 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2013-07-21 02:08:59 -0400 |
commit | 1d30b6b9b4413313abe1dca3bf9d4e01cdbb7979 (patch) | |
tree | f146b7763fea5cd4ba770877471bdc39db169560 | |
parent | 7ebe1296fc179e63be67e3de84ec2caf9f55be13 (diff) | |
download | decorator-user-account-parity.tar.gz |
Use the is_active parameter to toggle users ability to submituser-account-parity
-rw-r--r-- | store.py | 17 | ||||
-rw-r--r-- | webui.py | 4 |
2 files changed, 21 insertions, 0 deletions
@@ -1653,6 +1653,23 @@ class Store: ) return otkv + def user_active(self, username): + """ + Determines if the user is active (allowed to login) + """ + cursor = self.get_cursor() + sql = "SELECT is_active FROM accounts_user WHERE username = %s" + safe_execute(cursor, sql, (username,)) + return cursor.fetchone()[0] + + def activate_user(self, username): + """ + Activates the given user + """ + cursor = self.get_cursor() + sql = "UPDATE accounts_user SET is_active = TRUE WHERE username = %s" + safe_execute(cursor, sql, (username,)) + _User = FastResultRow('name password email gpg_keyid last_login!') def get_user(self, name): ''' Retrieve info about the user from the database. @@ -625,6 +625,8 @@ class WebUI: raise Unauthorised if self.store.get_otk(self.username): raise Unauthorised, "Incomplete registration; check your email" + if not self.store.user_active(self.username): + raise Unauthorised("Inactive User") # handle the action if action in '''debug home browse rss index search submit doap @@ -2807,6 +2809,8 @@ class WebUI: return # OK, delete the key self.store.delete_otk(info['otk']) + user = self.store.get_user_by_otk(info['otk']) + self.store.activate_user(user["name"]) self.write_template('message.pt', title='Registration complete', message='You are now registered.', url='%s?:action=login' % self.url_path, |