Skip to content
Permalink
Browse files Browse the repository at this point in the history
Redis and Hide Email Address fixes
Closes #97.
  • Loading branch information
hwittenborn committed Jul 25, 2022
1 parent 908b81a commit d13e3f2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
10 changes: 8 additions & 2 deletions aurweb/routers/accounts.py
Expand Up @@ -270,7 +270,7 @@ async def account_register_post(
request: Request,
U: str = Form(default=str()), # Username
E: str = Form(default=str()), # Email
H: str = Form(default=False), # Hide Email
H: str = Form(default="off"), # Hide Email
BE: str = Form(default=None), # Backup Email
R: str = Form(default=""), # Real Name
HP: str = Form(default=None), # Homepage
Expand Down Expand Up @@ -313,13 +313,19 @@ async def account_register_post(
models.AccountType, models.AccountType.AccountType == "User"
).first()

# Check if we should turn on HideEmail.
if H == "on":
hide_email = 1
else:
hide_email = 0

# Create a user given all parameters available.
with db.begin():
user = db.create(
models.User,
Username=U,
Email=E,
HideEmail=H,
HideEmail=hide_email,
BackupEmail=BE,
RealName=R,
Homepage=HP,
Expand Down
2 changes: 1 addition & 1 deletion docker/redis-entrypoint.sh
@@ -1,6 +1,6 @@
#!/bin/bash
set -eou pipefail

sed -ri 's/^bind .*$/bind 0.0.0.0 -::1/g' /etc/redis/redis.conf
sed -ri -e 's/^bind .*$/bind 0.0.0.0 -::1/g' -e 's/^protected-mode .*$/protected-mode no/g' /etc/redis/redis.conf

exec "$@"
4 changes: 4 additions & 0 deletions templates/account/show.html
Expand Up @@ -19,7 +19,11 @@ <h2>{% trans %}Accounts{% endtrans %} - {{ user.Username }}</h2>
</div>
<div class="item">
<p class="caption">{% trans %}Email Address{% endtrans %}:</p>
{% if request.user != user and user.HideEmail == 1 %}
<p class="data">None</a></p>
{% else %}
<p class="data"><a href="mailto:{{ user.Email }}">{{ user.Email }}</a></p>
{% endif %}
</div>
<div class="item">
<p class="caption">{% trans %}Real Name{% endtrans %}:</p>
Expand Down
2 changes: 1 addition & 1 deletion templates/partials/account_form.html
Expand Up @@ -82,7 +82,7 @@ <h2>{% trans %}Account Type{% endtrans %}:</h2>
{% trans %}Hide Email Address{% endtrans %}:
</label>

<input class="checkbox" id="id_hide" type="checkbox" name="H" {% if H %}checked="checked"{% endif %}>
<input class="checkbox" id="id_hide" type="checkbox" name="H" value="on" {% if H or request.user.HideEmail == 1 %}checked="checked"{% endif %}>
</div>
<p class="comment"><em>{{ "If you do not hide your email address, it is "
"visible to all registered MPR users. If you hide your "
Expand Down

0 comments on commit d13e3f2

Please sign in to comment.