def makeAdminUser(): admin = User.objects.create_superuser("admin", "*****@*****.**", "yacfadmin") admin.first_name = "Admin" profile = Profile(user=admin, verified=True, hidden=True) admin.save() profile.save()
def makeAdminUser(): admin = User.objects.create_superuser("admin", "*****@*****.**", "password1", first_name="Admin", last_name="Admin") admin.save() profile = Profile(user=admin, verified=True) profile.save()
def makeUser(user_name, user_email, user_password, user_team, hidden): # Validate admin user command line arguments validate_username(user_name) validate_email(user_email) validate_password(user_password) # Create team for admin user # user_team = Team(name=user_name, hidden=hidden) # user_team.save() user = User(username=user_name, email=user_email, first_name=user_name, last_name=user_name) user.set_password(user_password) user.save() profile = Profile(user=user, verified=True, team=user_team, hidden=hidden) profile.save()
def mutate(self, info, username, password, firstname, lastname, key): try: registerkey = AdminRegisterKey.objects.get(key=key) except: raise Exception("Key does not exist") if registerkey.expiration < timezone.now(): raise Exception("Expired Key") elif not registerkey.active: raise Exception("Not active access key") if User.objects.filter(username=username).first(): raise Exception("Username taken") validate_password(password) user = User.objects.create_superuser(username=username, password=password, first_name=firstname, last_name=lastname, email="") user.save() profile = Profile(user=user, verified=True, hidden=True) profile.save() if registerkey.singleuse: registerkey.active = False registerkey.save() try: logintracker = LoginTracker( user=user, address=info.context.META.get('HTTP_X_REAL_IP'), agent=info.context.META.get('HTTP_USER_AGENT')) logintracker.save() except: pass login(info.context, user) return CreateAdmin(code=0)
def mutate(self, info, username, email, password, firstname, lastname, accesscode): validate_user_is_admin(info.context.user) team = Team.objects.filter(accesscode=accesscode).first() if team: newUser = User.objects.create_user(username=username, first_name=firstname, last_name=lastname, email=email, password=password) newProfile = Profile(user=newUser, verified=False, team=team, hidden=False) newProfile.save() code = 0 else: # Invaild access code code = 1 login(info.context, newUser) return AddUser(code=code)
def mutate(self, info, username, email, password, firstname, lastname, accesscode): # validate_user_is_admin(info.context.user) validate_password(password) try: team = AccessCode.objects.get(value=accesscode).team except: raise Exception("Bad Access code") if team.players.count() <= S_Team.objects.first().capacity: newUser = User.objects.create_user(username=username, first_name=firstname, last_name=lastname, email=email, password=password) newProfile = Profile(user=newUser, verified=False, team=team, hidden=False) newProfile.save() else: raise Exception("Team is full") try: logintracker = LoginTracker( user=userobj, address=info.context.META.get('HTTP_X_REAL_IP'), agent=info.context.META.get('HTTP_USER_AGENT')) logintracker.save() except: pass login(info.context, newUser) return AddUser(code=0)