Skip to content

Commit

Permalink
fix error when user logs out, go back to /dashboard and has the serve…
Browse files Browse the repository at this point in the history
…r error (#2003)

* fix error when user logs out, go back to /dashboard and has the server error

* reformat files. Not run ruff on migrations/ and .venv

---------

Co-authored-by: Son NK <son@simplelogin.io>
  • Loading branch information
nguyenkims and Son NK authored Jan 5, 2024
1 parent a731bf4 commit 4a046c5
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 74 deletions.
2 changes: 1 addition & 1 deletion app/dashboard/views/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def get_stats(user: User) -> Stats:


@dashboard_bp.route("/", methods=["GET", "POST"])
@login_required
@limiter.limit(
ALIAS_LIMIT,
methods=["POST"],
exempt_when=lambda: request.form.get("form-name") != "create-random-email",
)
@limiter.limit("10/minute", methods=["GET"], key_func=lambda: current_user.id)
@login_required
@parallel_limiter.lock(
name="alias_creation",
only_when=lambda: request.form.get("form-name") == "create-random-email",
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ exclude = '''

[tool.ruff]
ignore-init-module-imports = true
exclude = [".venv", "migrations"]

[tool.djlint]
indent = 2
Expand Down
4 changes: 3 additions & 1 deletion templates/dashboard/unsubscribe.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ <h1 class="h3">Deactivate alias</h1>
You are about to deactivate the alias
<a href="mailto:{{ alias }}" target="_blank">{{ alias }}</a>
</p>
<p>After this, you will stop receiving all emails sent to this alias, please confirm. You will always be able to re-activate it untill you will decide to delete it.</p>
<p>
After this, you will stop receiving all emails sent to this alias, please confirm. You will always be able to re-activate it untill you will decide to delete it.
</p>
<form method="post">
<button class="btn btn-warning">Confirm</button>
</form>
Expand Down
4 changes: 0 additions & 4 deletions templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ <h3 class="h4 text-white">Developer</h3>
alt="GitHub">
</a>
</li>

<li>
<a class="list-group-item text-white footer-item "
href="https://status.simplelogin.io/">Status</a>
Expand All @@ -55,12 +54,10 @@ <h3 class="h4 text-white">Company</h3>
<a class="list-group-item text-white footer-item"
href="https://simplelogin.io/blog/">Blog</a>
</li>

<li>
<a class="list-group-item text-white footer-item"
href="https://simplelogin.io/about/">About Us</a>
</li>

<li>
<a class="list-group-item text-white footer-item"
href="https://simplelogin.io/contact/">Contact Us</a>
Expand Down Expand Up @@ -100,7 +97,6 @@ <h3 class="h4 text-white">Resources</h3>
</li>
</ul>
</div>

<div class="col-sm-4 col-lg-2 mb-4">
<h3 class="h4 text-white">Downloads</h3>
<ul class="list-group list-group-transparent list-group-white list-group-flush list-group-borderless mb-0 footer-list-group">
Expand Down
136 changes: 68 additions & 68 deletions templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,86 +89,86 @@
Github repo
<i class="fa fa-external-link" aria-hidden="true"></i>
</a>
<div class="dropdown-item">
<a href="https://forum.simplelogin.io"
target="_blank"
rel="noopener noreferrer">
Forum
<i class="fa fa-external-link" aria-hidden="true"></i>
</a>
</div>
<div class="dropdown-item">
<a href="/dashboard/support">Support</a>
<div class="dropdown-item">
<a href="https://forum.simplelogin.io"
target="_blank"
rel="noopener noreferrer">
Forum
<i class="fa fa-external-link" aria-hidden="true"></i>
</a>
</div>
<div class="dropdown-item">
<a href="/dashboard/support">Support</a>
</div>
</div>
</div>
</div>
{% else %}
<div class="nav-item">
<a href="https://simplelogin.io/docs/"
target="_blank"
rel="noopener noreferrer">
Docs
<i class="fa fa-external-link" aria-hidden="true"></i>
</a>
</div>
{% endif %}
{% if current_user.should_show_upgrade_button() %}

<div class="nav-item">
<a href="{{ url_for('dashboard.pricing') }}"
class="btn btn-sm btn-outline-primary">Upgrade</a>
</div>
{% endif %}
<div class="dropdown">
<a href="#" class="nav-link pr-0 leading-none" data-toggle="dropdown">
{% if current_user.profile_picture_id %}
{% else %}
<div class="nav-item">
<a href="https://simplelogin.io/docs/"
target="_blank"
rel="noopener noreferrer">
Docs
<i class="fa fa-external-link" aria-hidden="true"></i>
</a>
</div>
{% endif %}
{% if current_user.should_show_upgrade_button() %}

<span class="avatar"
style="background-image: url('{{ current_user.profile_picture_url() }}')"></span>
{% else %}
<span class="avatar avatar-blue">{{ current_user.get_name_initial() or "👻" }}</span>
{% endif %}
<span class="ml-2 d-none d-lg-block">
<span class="text-default text-break">{{ current_user.name or current_user.email }}</span>
{% if current_user.in_trial() %}
<div class="nav-item">
<a href="{{ url_for('dashboard.pricing') }}"
class="btn btn-sm btn-outline-primary">Upgrade</a>
</div>
{% endif %}
<div class="dropdown">
<a href="#" class="nav-link pr-0 leading-none" data-toggle="dropdown">
{% if current_user.profile_picture_id %}

<small class="text-success d-block mt-1"
data-toggle="tooltip"
title="When you signed up, you have a free 7-day Premium trial. After that your account will automatically be downgraded to the Free plan. During the trial, the only limit is you can't create more than {{ MAX_NB_EMAIL_FREE_PLAN }} aliases.">
Premium expires {{ current_user.trial_end|dt }}
<i class="fe fe-info"></i>
</small>
{% elif current_user.is_premium() %}
<small class="text-success d-block mt-1">Premium</small>
<span class="avatar"
style="background-image: url('{{ current_user.profile_picture_url() }}')"></span>
{% else %}
<span class="avatar avatar-blue">{{ current_user.get_name_initial() or "👻" }}</span>
{% endif %}
</span>
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
<a class="dropdown-item mb-3" href="{{ url_for('dashboard.api_key') }}">
<i class="dropdown-icon fa fa-key"></i> API Keys
</a>
<a class="dropdown-item" href="{{ url_for('auth.logout') }}">
<i class="dropdown-icon fe fe-log-out"></i> Sign out
<span class="ml-2 d-none d-lg-block">
<span class="text-default text-break">{{ current_user.name or current_user.email }}</span>
{% if current_user.in_trial() %}

<small class="text-success d-block mt-1"
data-toggle="tooltip"
title="When you signed up, you have a free 7-day Premium trial. After that your account will automatically be downgraded to the Free plan. During the trial, the only limit is you can't create more than {{ MAX_NB_EMAIL_FREE_PLAN }} aliases.">
Premium expires {{ current_user.trial_end|dt }}
<i class="fe fe-info"></i>
</small>
{% elif current_user.is_premium() %}
<small class="text-success d-block mt-1">Premium</small>
{% endif %}
</span>
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
<a class="dropdown-item mb-3" href="{{ url_for('dashboard.api_key') }}">
<i class="dropdown-icon fa fa-key"></i> API Keys
</a>
<a class="dropdown-item" href="{{ url_for('auth.logout') }}">
<i class="dropdown-icon fe fe-log-out"></i> Sign out
</a>
</div>
</div>
</div>
<a href="#"
class="header-toggler d-lg-none ml-3 ml-lg-0"
data-toggle="collapse"
data-target="#headerMenuCollapse">
<span class="header-toggler-icon"></span>
</a>
</div>
<a href="#"
class="header-toggler d-lg-none ml-3 ml-lg-0"
data-toggle="collapse"
data-target="#headerMenuCollapse">
<span class="header-toggler-icon"></span>
</a>
</div>
</div>
</div>
<div class="header collapse d-lg-flex p-0" id="headerMenuCollapse">
<div class="container">
<div class="row align-items-center">
<div class="col-lg order-lg-first">
{% include "menu.html" %}
<div class="header collapse d-lg-flex p-0" id="headerMenuCollapse">
<div class="container">
<div class="row align-items-center">
<div class="col-lg order-lg-first">
{% include "menu.html" %}

</div>
</div>
</div>
</div>
</div>

0 comments on commit 4a046c5

Please sign in to comment.