Skip to content

Commit

Permalink
consistently use login instead of signin
Browse files Browse the repository at this point in the history
  • Loading branch information
dansahagian committed Jul 26, 2024
1 parent 0c49523 commit f30871c
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions fbsurvivor/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def save(self, *args, **kwargs):

if not pk:
ps = f"If you didn't sign up, please email {settings.CONTACT}"
signin = f"{settings.DOMAIN}"
login = f"{settings.DOMAIN}"
subject = "Survivor User Account"
recipients = [self.email]
message = f"You can login here:\n\n{signin}\n\n{ps}"
message = f"You can login here:\n\n{login}\n\n{ps}"

send_email(subject, recipients, message)

Expand Down
6 changes: 3 additions & 3 deletions fbsurvivor/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
assume,
board,
board_redirect,
theme,
enter,
get_players,
login,
logout,
manager,
manager_redirect,
Expand All @@ -26,13 +26,13 @@
seasons,
send_message,
send_message_all,
signin,
theme,
update_reminders,
user_paid,
)

urlpatterns = [
path("", signin, name="signin"),
path("", login, name="login"),
path("logout", logout, name="logout"),
path("enter/<str:token>/", enter, name="enter"),
path("assume/<str:username>/", assume, name="assume"),
Expand Down
8 changes: 4 additions & 4 deletions fbsurvivor/core/utils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def inner(*args, **kwargs):
return view(*args, **kwargs)
request.session.delete("token")

return redirect(reverse("signin"))
return redirect(reverse("login"))

return inner

Expand All @@ -52,7 +52,7 @@ def inner(*args, **kwargs):
return view(*args, **kwargs)
request.session.delete("token")

return redirect(reverse("signin"))
return redirect(reverse("login"))

return inner

Expand Down Expand Up @@ -101,6 +101,6 @@ def get_season_context(year: int, **kwargs) -> (Season, dict):

def send_magic_link(player: Player) -> None:
token = create_token(player)
subject = "Survivor Sign in"
message = f"Click the link below to signin\n\n{DOMAIN}/enter/{token}"
subject = "Survivor Login"
message = f"Click the link below to login\n\n{DOMAIN}/enter/{token}"
send_email(subject, [player.email], message)
4 changes: 3 additions & 1 deletion fbsurvivor/core/utils/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@


def send_email(subject, recipients, message) -> None:
subject = f"🏈 {subject} 🏈"

if ENV == "dev":
print(f"\n\nSending Email to {len(recipients)} players...\n{subject}\n\n{message}\n\n")
return None

msg = MIMEText(message)
msg["Subject"] = f"🏈 {subject} 🏈"
msg["Subject"] = subject
msg["From"] = SMTP_SENDER
msg["To"] = SMTP_SENDER

Expand Down
2 changes: 1 addition & 1 deletion fbsurvivor/core/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def send_to_latest_season_played(request):
return redirect(reverse("board", args=[latest]))
else:
messages.info(request, "We don't have a record of you playing any season.")
return redirect(reverse("signin"))
return redirect(reverse("login"))


def update_player_records(year: int) -> int:
Expand Down
8 changes: 4 additions & 4 deletions fbsurvivor/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
from fbsurvivor.settings import CONTACT, VENMO


def signin(request):
def login(request):
if request.method == "GET":
if request.session.get("token"):
return redirect(reverse("board_redirect"))

context = {
"form": EmailForm(),
}
return render(request, "signin.html", context=context)
return render(request, "fbsurvivor/templates/login.html", context=context)

if request.method == "POST":
form = EmailForm(request.POST)
Expand All @@ -56,7 +56,7 @@ def signin(request):
except Player.DoesNotExist:
pass

return render(request, "signin-sent.html")
return render(request, "fbsurvivor/templates/login-sent.html")


def enter(request, token):
Expand All @@ -70,7 +70,7 @@ def logout(request, **kwargs):
if token := request.session.get("token"):
TokenHash.objects.get(hash=get_token_hash(token)).delete()
request.session.delete("token")
return redirect(reverse("signin"))
return redirect(reverse("login"))


@authenticate_admin
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Have an account?<br><br>
Enter your email address!
<br><br>
<form action="{% url 'signin' %}" method="POST">
<form action="{% url 'login' %}" method="POST">
{% csrf_token %}
<label for="{{ form.email.id_for_label }}"></label>
{{ form.email }}
Expand Down
6 changes: 0 additions & 6 deletions fbsurvivor/templates/sent-magic-link.html

This file was deleted.

0 comments on commit f30871c

Please sign in to comment.