def get(self, google_tok): """Get request, looking for all users with google token. Args: google_tok (str[]): A list of google tokens to query with. Returns: json[]: A list of jsonified users. """ auth_error = auth.unauthorized_headers(request.headers) if auth_error: return auth_error user = UserModel.find_by_google_tok(google_tok) listing_IDs = [] if user: for listing in user.listings: listing_IDs.append(listing.listing_id) return { 'google_tok': user.google_tok, 'imageURL': user.imageURL, "email": user.email, "name": user.name, "givenName": user.givenName, 'familyName': user.familyName, "listings": listing_IDs } return {"message": "user not found"}, 404
def get(self, tokens): """Gets a list of all users in database that match any token from a list of tokens.. Args: tokens (str[]): A list of tokens to query with. Returns: json[]: A list of jsonified users that match the tokens. """ auth_error = auth.unauthorized_headers(request.headers) if auth_error: return auth_error tokens = tokens.split(",") all_users = UserModel.query.filter( UserModel.google_tok.in_(tokens)).all() return {"users": [user.bare_json() for user in all_users]}