user can remove the app link
This commit is contained in:
parent
efae1710c8
commit
9757b12b95
|
@ -11,7 +11,7 @@
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h1 class="h3"> Apps </h1>
|
<h1 class="h3"> Apps </h1>
|
||||||
<div class="small-text">
|
<div class="small-text">
|
||||||
List of websites/apps that you have used <b>Sign in with SimpleLogin</b> on
|
List of websites/apps that you have used <b>Sign in with SimpleLogin</b>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -29,12 +29,15 @@
|
||||||
<th>
|
<th>
|
||||||
Info
|
Info
|
||||||
<i class="fe fe-help-circle" data-toggle="tooltip"
|
<i class="fe fe-help-circle" data-toggle="tooltip"
|
||||||
title="Info sent to this app/website"></i>
|
title="Info this app/website receives"></i>
|
||||||
</th>
|
</th>
|
||||||
<th class="text-center">
|
<th>
|
||||||
First used
|
First used
|
||||||
<i class="fe fe-help-circle" data-toggle="tooltip"
|
<i class="fe fe-help-circle" data-toggle="tooltip"
|
||||||
title="The first time you have used the SimpleLogin on this app/website"></i>
|
title="The first time you have used the 'Sign in with SimpleLogin' button on this app/website"></i>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Actions
|
||||||
</th>
|
</th>
|
||||||
<!--<th class="text-center">Last used</th>-->
|
<!--<th class="text-center">Last used</th>-->
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -58,10 +61,18 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="text-center">
|
<td>
|
||||||
{{ client_user.created_at | dt }}
|
{{ client_user.created_at | dt }}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="client-user-id" value="{{ client_user.id }}">
|
||||||
|
<button class="btn btn-warning">
|
||||||
|
Remove
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
List of apps that user has used via the "Sign in with SimpleLogin"
|
List of apps that user has used via the "Sign in with SimpleLogin"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from flask import render_template
|
from flask import render_template, request, flash, redirect
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
from sqlalchemy.orm import joinedload
|
from sqlalchemy.orm import joinedload
|
||||||
|
|
||||||
from app.dashboard.base import dashboard_bp
|
from app.dashboard.base import dashboard_bp
|
||||||
|
from app.extensions import db
|
||||||
from app.models import (
|
from app.models import (
|
||||||
ClientUser,
|
ClientUser,
|
||||||
)
|
)
|
||||||
|
@ -24,6 +25,22 @@ def app_route():
|
||||||
|
|
||||||
sorted(client_users, key=lambda cu: cu.client.name)
|
sorted(client_users, key=lambda cu: cu.client.name)
|
||||||
|
|
||||||
|
if request.method == "POST":
|
||||||
|
client_user_id = request.form.get("client-user-id")
|
||||||
|
client_user = ClientUser.get(client_user_id)
|
||||||
|
if not client_user or client_user.user_id != current_user.id:
|
||||||
|
flash(
|
||||||
|
"Unknown error, sorry for the inconvenience, refresh the page", "error"
|
||||||
|
)
|
||||||
|
return redirect(request.url)
|
||||||
|
|
||||||
|
client = client_user.client
|
||||||
|
ClientUser.delete(client_user_id)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
flash(f"Link with {client.name} has been removed", "success")
|
||||||
|
return redirect(request.url)
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"dashboard/app.html",
|
"dashboard/app.html",
|
||||||
client_users=client_users,
|
client_users=client_users,
|
||||||
|
|
Loading…
Reference in New Issue