Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions ui/app/controllers/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@
Transaction,
)
from app.stats_helpers import fetch_stats_bundle
from flask import Blueprint, flash, jsonify, redirect, render_template, request, url_for
from flask import (
Blueprint,
flash,
g,
jsonify,
redirect,
render_template,
request,
url_for,
)
from flask_wtf import FlaskForm
from wtforms import (
BooleanField,
Expand Down Expand Up @@ -355,7 +364,11 @@ def detail(id):
stats_limit = max(1, stats_limit)

api = get_refinance_api_client()
is_owner = bool(g.get("actor_entity") and g.actor_entity.get("id") == id)
if request.method == "POST":
if not is_owner:
flash("You can only manage your own cards.", "error")
return redirect(url_for("entity.detail", id=id))
action = (request.form.get("stripe_action") or "").strip().lower()
try:
if action == "add":
Expand Down Expand Up @@ -480,7 +493,7 @@ def detail(id):
.get("total", 0)
)

if Config.STRIPE_CONFIGURED:
if Config.STRIPE_CONFIGURED and is_owner:
authorizations_resp = api.http(
"GET",
"deposits/providers/stripe/authorizations",
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/entity/detail.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
{% endif %}
</section>

{% if stripe_configured %}
{% if stripe_configured and g.actor_entity and g.actor_entity.id == entity.id %}
<section class="entity-card entity-stripe-card">
<h3 class="entity-card-title">Stripe Cards</h3>

Expand Down
Loading