Git based wiki inspired by Gollum
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
860B

  1. import click
  2. from realms.lib.util import random_string
  3. from realms.modules.auth.models import User
  4. from realms.lib.util import green, red, yellow
  5. @click.group(short_help="Auth Module")
  6. def cli():
  7. pass
  8. @cli.command()
  9. @click.argument('username')
  10. @click.argument('email')
  11. @click.option('--password', help='Leave blank for random password')
  12. def create_user(username, email, password):
  13. """ Create a new user
  14. """
  15. show_pass = not password
  16. if not password:
  17. password = random_string(12)
  18. if User.get_by_username(username):
  19. red("Username %s already exists" % username)
  20. return
  21. if User.get_by_email(email):
  22. red("Email %s already exists" % email)
  23. return
  24. User.create(username, email, password)
  25. green("User %s created" % username)
  26. if show_pass:
  27. yellow("Password: %s" % password)