def create_user(self): ''' Add user to the database ''' if User.by_handle(self.get_argument('handle', '')) is not None: raise ValidationError("This hacker name is already registered") if self.get_argument('pass1', '') != self.get_argument('pass2', ''): raise ValidationError("Passwords do not match") user = User() user.handle = self.get_argument('handle', '') user.password = self.get_argument('pass1', '') user.bank_password = self.get_argument('bpass', '') user.name = self.get_argument('playername', '') user.email = self.get_argument('email', '') team = self.get_team() self.dbsession.add(user) self.dbsession.add(team) self.dbsession.commit() # Avatar avatar_select = self.get_argument('user_avatar_select', '') if avatar_select and len(avatar_select) > 0: user._avatar = avatar_select elif hasattr(self.request, 'files') and 'avatar' in self.request.files: user.avatar = self.request.files['avatar'][0]['body'] team.members.append(user) if not options.teams: if avatar_select and len(avatar_select) > 0: team._avatar = avatar_select elif hasattr(self.request, 'files') and 'avatar' in self.request.files: team.avatar = self.request.files['avatar'][0]['body'] self.dbsession.add(user) self.dbsession.add(team) self.dbsession.commit() self.event_manager.user_joined_team(user) return user
def create_user(self): ''' Add user to the database ''' if User.by_handle(self.get_argument('handle', '')) is not None: raise ValidationError("This handle is already registered") if self.get_argument('pass1', '') != self.get_argument('pass2', ''): raise ValidationError("Passwords do not match") user = User() user.handle = self.get_argument('handle', '') user.password = self.get_argument('pass1', '') user.bank_password = self.get_argument('bpass', '') user.name = self.get_argument('playername', '') user.email = self.get_argument('email','') team = self.get_team() self.dbsession.add(user) self.dbsession.add(team) self.dbsession.commit() # Avatar avatar_select = self.get_argument('user_avatar_select', '') if avatar_select and len(avatar_select) > 0: user._avatar = avatar_select elif hasattr(self.request, 'files') and 'avatar' in self.request.files: user.avatar = self.request.files['avatar'][0]['body'] team.members.append(user) if not options.teams: if avatar_select and len(avatar_select) > 0: team._avatar = avatar_select elif hasattr(self.request, 'files') and 'avatar' in self.request.files: team.avatar = self.request.files['avatar'][0]['body'] self.dbsession.add(user) self.dbsession.add(team) self.dbsession.commit() self.event_manager.user_joined_team(user) return user
def create_user(self): """ Add user to the database """ if User.by_handle(self.get_argument("handle", "")) is not None: raise ValidationError("This handle is already registered") if self.get_argument("pass1", "") != self.get_argument("pass2", ""): raise ValidationError("Passwords do not match") user = User() user.handle = self.get_argument("handle", "") user.password = self.get_argument("pass1", "") user.bank_password = self.get_argument("bpass", "") user.name = self.get_argument("playername", "") user.email = self.get_argument("email", "") team = self.get_team() self.dbsession.add(user) self.dbsession.add(team) self.dbsession.commit() # Avatar avatar_select = self.get_argument("user_avatar_select", "") if avatar_select and len(avatar_select) > 0: user._avatar = avatar_select elif hasattr(self.request, "files") and "avatar" in self.request.files: user.avatar = self.request.files["avatar"][0]["body"] team.members.append(user) if not options.teams: if avatar_select and len(avatar_select) > 0: team._avatar = avatar_select elif hasattr(self.request, "files") and "avatar" in self.request.files: team.avatar = self.request.files["avatar"][0]["body"] self.dbsession.add(user) self.dbsession.add(team) self.dbsession.commit() self.event_manager.user_joined_team(user) return user
def create_user(): user = User.by_handle("HacKer") if user is None: user = User() user.handle = "HacKer" user.password = "******" user.bank_password = "******" dbsession.add(user) dbsession.commit() return user
def create_user(): user = User.by_handle("HacKer") if user is None: user = User() user.handle = "HacKer" user.password = "******" user.bank_password = "******" dbsession.add(user) dbsession.commit() return user
def create_user(self): """ Add user to the database """ self.form_validation() user = User() user.handle = self.get_argument("handle", "") user.password = self.get_argument("pass1", "") user.bank_password = self.get_argument("bpass", "") user.name = self.get_argument("playername", "") user.email = self.get_argument("email", "") user.theme = options.default_theme team = self.get_team() self.dbsession.add(user) self.dbsession.add(team) self.dbsession.commit() # Avatar avatar_select = self.get_argument("user_avatar_select", "") if avatar_select and len(avatar_select) > 0: user._avatar = avatar_select elif hasattr(self.request, "files") and "avatar" in self.request.files: user.avatar = self.request.files["avatar"][0]["body"] else: user._avatar = identicon(user.handle, 6) team.members.append(user) if not options.teams: if avatar_select and len(avatar_select) > 0: team._avatar = avatar_select elif hasattr(self.request, "files") and "avatar" in self.request.files: team.avatar = self.request.files["avatar"][0]["body"] else: team._avatar = identicon(user.handle, 6) self.dbsession.add(user) self.dbsession.add(team) self.dbsession.commit() if ( options.require_email and options.validate_email and len(options.mail_host) > 0 ): self.send_validate_message(user) user.locked = True self.dbsession.add(user) self.dbsession.commit() else: self.event_manager.user_joined_team(user) # Chat if self.chatsession: self.chatsession.create_user(user, self.get_argument("pass1", "")) return user
def create_user(self, team): ''' Add user to the database ''' if self.get_argument('pass1', '') != self.get_argument('pass2', ''): raise ValidationError("Passwords do not match") user = User() user.handle = self.get_argument('handle', '') user.password = self.get_argument('pass1', '') user.bank_password = self.get_argument('bpass', '') team.members.append(user) self.dbsession.add(user) self.dbsession.add(team) self.dbsession.commit() self.event_manager.user_joined_team(user) return user
def create_user(self, team): ''' Add user to the database ''' if self.get_argument('pass1', '') != self.get_argument('pass2', ''): raise ValidationError("Passwords do not match") user = User() user.handle = self.get_argument('handle', '') user.password = self.get_argument('pass1', '') user.bank_password = self.get_argument('bpass', '') team.members.append(user) self.dbsession.add(user) self.dbsession.add(team) self.dbsession.commit() self.event_manager.user_joined_team(user) return user
def add_user(self, claims, team_code): user = User() user.uuid = claims["oid"] user.handle = claims["preferred_username"].split("@")[0] # Generate a long random password that the user will never know or use. user.password = "".join( secrets.choice(string.ascii_letters + string.digits + string.punctuation) for i in range(30)) user.bank_password = "" user.name = claims["name"] user.email = claims["email"] user.theme = options.default_theme user.last_login = datetime.now() user.logins = 1 if not self.is_admin(claims): user.team = Team.by_code(team_code) self.dbsession.add(user) return user