Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -155,5 +155,33 @@ def revogar_processo(processo_id):
|
|
| 155 |
|
| 156 |
|
| 157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
if __name__ == "__main__":
|
| 159 |
app.run(host="0.0.0.0", port=7860)
|
|
|
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
+
@app.route("/api/me", methods=["GET"])
|
| 159 |
+
def me():
|
| 160 |
+
auth_header = request.headers.get("Authorization")
|
| 161 |
+
|
| 162 |
+
if not auth_header:
|
| 163 |
+
abort(401)
|
| 164 |
+
|
| 165 |
+
try:
|
| 166 |
+
token = auth_header.split(" ")[1]
|
| 167 |
+
decoded = verify_token(token)
|
| 168 |
+
user_id = decoded["sub"]
|
| 169 |
+
except:
|
| 170 |
+
abort(401)
|
| 171 |
+
|
| 172 |
+
# Buscar usuário na sua tabela pública
|
| 173 |
+
result = supabase.table("users") \
|
| 174 |
+
.select("id, nome, role") \
|
| 175 |
+
.eq("id", user_id) \
|
| 176 |
+
.single() \
|
| 177 |
+
.execute()
|
| 178 |
+
|
| 179 |
+
if not result.data:
|
| 180 |
+
abort(403)
|
| 181 |
+
|
| 182 |
+
return jsonify(result.data)
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
|
| 186 |
if __name__ == "__main__":
|
| 187 |
app.run(host="0.0.0.0", port=7860)
|