Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password resetting #74

Merged
merged 47 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5fe0244
god help me
MaxIsJoe Jan 13, 2024
e7607bf
Update src/accounts/api/views.py
MaxIsJoe Jan 13, 2024
4b83cfa
fix save error
MaxIsJoe Jan 17, 2024
8d95ffb
remove account identifier from url
MaxIsJoe Jan 17, 2024
1234969
Update views.py
MaxIsJoe Jan 17, 2024
105cddf
fixes multiple arguments error
MaxIsJoe Jan 17, 2024
f20604b
random token
MaxIsJoe Jan 17, 2024
6264445
cacwka
MaxIsJoe Jan 17, 2024
c06af96
password resting works, woohoo!
MaxIsJoe Jan 17, 2024
833e69e
Update views.py
MaxIsJoe Jan 17, 2024
88614c8
token time lifespan
MaxIsJoe Jan 18, 2024
cab7dff
Update serializers.py
MaxIsJoe Jan 18, 2024
42b6a81
Update serializers.py
MaxIsJoe Jan 18, 2024
ad6fef7
Update models.py
MaxIsJoe Jan 18, 2024
edffbae
Update models.py
MaxIsJoe Jan 18, 2024
fd41b67
hour
MaxIsJoe Jan 18, 2024
395f686
view request changes
MaxIsJoe Jan 18, 2024
e9feb9f
name changes
MaxIsJoe Jan 18, 2024
498df54
remove some logs
MaxIsJoe Jan 18, 2024
4b60944
Update urls.py
MaxIsJoe Jan 18, 2024
eead438
Update urls.py
MaxIsJoe Jan 18, 2024
9c59243
Update urls.py
MaxIsJoe Jan 18, 2024
d8faa5e
precommit
MaxIsJoe Jan 18, 2024
69b8684
Update urls.py
MaxIsJoe Jan 18, 2024
34743a4
Update serializers.py
MaxIsJoe Jan 18, 2024
bde9f50
Update models.py
MaxIsJoe Jan 18, 2024
d32bef7
Update models.py
MaxIsJoe Jan 19, 2024
647c29a
e
MaxIsJoe Jan 19, 2024
ab501dc
email
MaxIsJoe Jan 21, 2024
7cb9285
Update views.py
MaxIsJoe Jan 21, 2024
6d03d36
Update views.py
MaxIsJoe Jan 21, 2024
341bf19
Update serializers.py
MaxIsJoe Jan 21, 2024
d83f73a
ee
MaxIsJoe Jan 21, 2024
95e1694
Update views.py
MaxIsJoe Jan 21, 2024
e0b3115
link correct
MaxIsJoe Jan 21, 2024
ada8c01
get email
MaxIsJoe Jan 21, 2024
27027ce
Update serializers.py
MaxIsJoe Jan 21, 2024
010ce67
password request
MaxIsJoe Jan 21, 2024
eed561a
Update views.py
MaxIsJoe Jan 21, 2024
c16d236
Update views.py
MaxIsJoe Jan 21, 2024
1cdbe5d
fixes an error with subscriptables
MaxIsJoe Jan 21, 2024
07fc838
Update src/accounts/api/serializers.py
MaxIsJoe Jan 22, 2024
1ccc17e
Merge remote-tracking branch 'upstream/develop' into forgetmepassword…
MaxIsJoe Jan 22, 2024
da3cef4
email working
MaxIsJoe Jan 22, 2024
9fcc842
Update serializers.py
MaxIsJoe Jan 22, 2024
7a04f96
Create 0001_squashed_0002_passwordresetrequest.py
MaxIsJoe Jan 23, 2024
f89154c
chore: make a single migration for the new model
corp-0 Jan 23, 2024
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
13 changes: 13 additions & 0 deletions src/accounts/api/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from uuid import uuid4

from central_command import settings
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
from django.core.mail import send_mail
from knox.models import AuthToken
from knox.views import LoginView as KnoxLoginView
from rest_framework import status
Expand Down Expand Up @@ -225,4 +227,15 @@ def post(self, request):
return Response(data={"detail": "Operation Done."}, status=status.HTTP_200_OK)
corp-0 marked this conversation as resolved.
Show resolved Hide resolved

serializer.save()
corp-0 marked this conversation as resolved.
Show resolved Hide resolved
send_mail(
"Password Reset Request",
"A password reset request has been made for your account.\n"
+ "Please visit the following link to reset your password: "
+ settings.APP_URL
+ serializer.data["token"]
+ "\n\nIf you have not made this request, please ignore this email. The link will expire within 35 minutes.",
settings.EMAIL_FROM_ADDRESS,
[serializer.data["account"].email],
fail_silently=False,
)
return Response(data={"detail": "Operation Done."}, status=status.HTTP_200_OK)
corp-0 marked this conversation as resolved.
Show resolved Hide resolved
corp-0 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions src/central_command/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
EMAIL_ADDRESS = os.environ.get("EMAIL_HOST_USER")
EMAIL_FROM_ADDRESS = os.environ.get("EMAIL_HOST_USER")
EMAIL_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD")
EMAIL_PASSWORD_RESET = os.environ.get("WEBSITE_URL", "https://unitystation.org/reset-password/")
corp-0 marked this conversation as resolved.
Show resolved Hide resolved
EMAIL_MAIL_SUBJECT = "Confirm your Unitystation account"
EMAIL_MAIL_HTML = "registration/confirmation_email.html"
EMAIL_PAGE_TEMPLATE = "confirm_template.html"
Expand Down