def post(self): caller = get_caller(request) if caller["role"] != "admin": return res("⛔️ Must be an admin to add a new client", "error"), 400 req = parse(request) errors = ClientListSchema().validate(req) if errors: return res("Errors in request", "alert", errors=errors), 400 client = Client(name=req["name"]) if "email" in req: client["email"] = req["email"].lower() client.save() return res("Added a new client", "success", client=convert_query(client))
def post(self): user = current_user.user() item = Client( client_id=gen_salt(40), client_secret=gen_salt(50), _redirect_uris=list([ 'http://localhost:8000/authorized', 'http://127.0.0.1:8000/authorized', 'http://127.0.1:8000/authorized', 'http://127.1:8000/authorized', ]), _default_scopes='email', user=user, ) try: item.save() except: return 'insert false' return jsonify( client_id = item.client_id, client_secret = item.client_secret )