def post(self): """ Creates a new account. """ # TODO: improved password handling? params = dict( first_name=request.json.get('first_name'), last_name=request.json.get('last_name'), birth_date=request.json.get('birth_date'), email=request.json.get('email'), gender=request.json.get('gender'), username=request.json.get('username'), password=request.json.get('password')) optional_params = dict( city_id=request.json.get('city_id')) missing_fields = [k for (k, v) in params.iteritems() if not v] if missing_fields: return (jsonify(build_error_dict([ 'No value specified for "%s".' % field for field in missing_fields])), 400, []) params.update(optional_params) user = User(**params) user.save(commit=True) return UserByIDHandler._get(user)
def get_logged_user(): """ Gets the currently logged user. """ return User.load_current_user(get_request_token())