def get(self): users = User.search_by_username(self.request.params) # Exclude current user return { "users": [ user.to_dict() for user in users if user.user_id != self.request.user.user_id ] }, 200
def ensure_register(self, username=None, password="******", email=None, station=None): if username is None: username = self.generator.username.generate() if email is None: email = self.generator.email.generate() bcrypted_password = UserModel.bcrypt_password(password) db = inject.instance('db') user_id = str(uuid.uuid4()) user = User.add(db, user_id, username, email, bcrypted_password) if station is not None: _ = self.subscribe(station.station_id, user.user_id) return user
def get(self): user = User.get_by_session(self.request.session) return { "user": user.to_dict(), "session_id": self.request.session.session_id }, 200
def patch(self, user_id): User.validate_avatar(self.request.body) user = User.update_avatar(user_id, self.request.body) return user.to_dict(), 200
def get(self, user_id): user = User.get(user_id) return user.to_dict(), 200
def post(self): User.validate_registration_payload(self.request.body) user = User.add(self.request.body) return user.to_dict(), 200
def wrapper(self, *args, **kw): user = User.get(self.request.session.user_id) self.request.user = user return func(self, *args, **kw)