Esempio n. 1
0
def reset_token_commands(args):
    if args.clear_reset:
        username = args.clear_reset
    else:
        username = args.reset

    user_info = userdb.get_user_info(username)

    if not user_info:
        err_exit("Reset/clear password failed; invalid user: %s" % username)

    # don't crash on the default config
    if config.get('lobby_url') is None:
        config.set('lobby_url', "[insert lobby url here]")

    if args.clear_reset:
        ok, msg = userdb.clear_password_token(username)
        if not ok:
            err_exit("Error clearing password reset token for %s: %s" %
                     (username, msg))
        else:
            print("Password reset token cleared for account '%s'." % username)
    else:
        ok, msg = userdb.generate_forgot_password(username)
        if not ok:
            err_exit("Error generating password reset token for %s: %s" %
                     (username, msg))
        else:
            if not user_info[1]:
                logging.warning("No email set for account '%s', use caution!" %
                                username)
            print("Setting a password reset token on account '%s'." % username)
            print("Email: %s\nMessage body to send to user:\n%s\n" %
                  (user_info[1], msg))
Esempio n. 2
0
 def admin_pw_reset(self, username):
     user_info = userdb.get_user_info(username)
     if not user_info:
         self.send_message("admin_pw_reset_done", error="Invalid user")
         return
     ok, msg = userdb.generate_forgot_password(username)
     if not ok:
         self.send_message("admin_pw_reset_done", error=msg)
     else:
         self.logger.info("Admin user '%s' set a password token on account '%s'", self.username, username)
         self.send_message("admin_pw_reset_done", email_body=msg, username=username, email=user_info[1])