@@ -0,0 +1,2064 @@
+%22%22%22%0AThis script can be run to generate a CSV output of accounts which do not have their passwords set, along%0Awith some useful account information, and possible explanations for the lack of password%0A%0A%60%60%60%0Apython accounts_with_missing_passwords.py -o accounts.csv%0A%60%60%60%0A%22%22%22%0Aimport esprit, codecs%0Afrom portality.core import app%0Afrom portality.clcsv import UnicodeWriter%0Afrom portality import models%0Afrom datetime import datetime%0A%0AMISSING_PASSWORD = %7B%0A    %22query%22 : %7B%0A        %22filtered%22 : %7B%0A            %22query%22 : %7B%0A                %22match_all%22 : %7B%7D%0A            %7D,%0A            %22filter%22 : %7B%0A                %22missing%22 : %7B%22field%22 : %22password%22%7D%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A%0A%0Aif __name__ == %22__main__%22:%0A%0A    import argparse%0A    parser = argparse.ArgumentParser()%0A    parser.add_argument(%22-o%22, %22--out%22, help=%22output file path%22)%0A    args = parser.parse_args()%0A%0A    if not args.out:%0A        print %22Please specify an output file path with the -o option%22%0A        parser.print_help()%0A        exit()%0A%0A    conn = esprit.raw.make_connection(None, app.config%5B%22ELASTIC_SEARCH_HOST%22%5D, None, app.config%5B%22ELASTIC_SEARCH_DB%22%5D)%0A%0A    with codecs.open(args.out, %22wb%22, %22utf-8%22) as f:%0A        writer = UnicodeWriter(f)%0A        writer.writerow(%5B%22ID%22, %22Name%22, %22Email%22, %22Created%22, %22Last Updated%22, %22Updated Since Create?%22, %22Has Reset Token%22, %22Rest Token Expired?%22%5D)%0A%0A        for a in esprit.tasks.scroll(conn, models.Account.__type__, q=MISSING_PASSWORD, page_size=100, keepalive='1m'):%0A            account = models.Account(_source=a)%0A%0A            has_reset = account.reset_token is not None%0A%0A            expires = account.reset_expires_timestamp%0A            is_expired = expires %3C datetime.utcnow()%0A%0A            updated_since_create = account.created_timestamp %3C account.last_updated_timestamp%0A%0A            writer.writerow(%5B%0A                account.id,%0A                account.name,%0A                account.email,%0A                account.created_date,%0A                account.last_updated,%0A                updated_since_create,%0A                has_reset,%0A                is_expired%0A            %5D)%0A

add a script which can identify and report on user accounts which are missing passwords