Skip to content

New flow changes #100

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

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open

New flow changes #100

wants to merge 9 commits into from

Conversation

Bod9001
Copy link
Member

@Bod9001 Bod9001 commented Aug 5, 2025

Is missing the job to clear out the old sha tokens
And maybe the time Expiry for character settings token?

@Bod9001 Bod9001 marked this pull request as ready for review August 10, 2025 15:06
@@ -5,15 +5,15 @@ meta {
}

post {
url: {{baseUrl}}/accounts/register
url: http://localhost:8000/accounts/register
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to use {{baseUrl}}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doeesn't seem to pull it automatically though, It's better just to use the One that is going to be most often used with in development?

}

post {
url: http://127.0.0.1:8000/accounts/check-SHA512-for-account/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

baseUrl

}

post {
url: http://127.0.0.1:8000/accounts/register-SHA512-for-account/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

baseUrl

}

post {
url: http://127.0.0.1:8000/persistence/characters/GenForkToken
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

baseUrl

@@ -5,11 +5,11 @@ meta {
}

get {
url: {{baseUrl}}/persistence/characters
url: http://127.0.0.1:8000/persistence/characters
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

baseUrl

}

get {
url: http://localhost:8000/persistence/characters/compatibleToken?character_sheet_version=1.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

baseUrl

operations = [
migrations.CreateModel(
name='SHA512Token',
fields=[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these all the fields that we migrate? or are there more?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk,This is automatically generated code


character_sheet_version = query_serializer.validated_data["character_sheet_version"]

return Character.objects.filter(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be handled with a trycatch before hand?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

@@ -0,0 +1,3 @@
meta {
name: SHAChecks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't commit bruno files. It was good before we had any auto documentation on the endpoints but now it will just confuse other developers. I'd say you can even remove the whole api-collection folder

ConfirmAccountView,
LoginWithCredentialsView,
LoginWithTokenView,
RegisterAccountView,
RegisterSHA512ForAccount,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Snep said SHA512 wasn't good enough for us. I would wait for his input here



class RegisterSHA512ForAccount(APIView):
class InputSerializer(serializers.Serializer):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't create serializers inside the view class. There is a serializers file for this purpose. Everything on their own file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the name for this serializer sucks. Follow the convention of the other serializers in the project


def post(self, request, *args, **kwargs):
user: Account = request.user
if not request.auth:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this view doesn't override the permission_classes field, it will use the default one which is IsAuthenticatedand handles the case where not valid auth token is passed, so this would not be needed.

try:
account = Account.objects.get(unique_identifier=unique_id)
except Account.DoesNotExist:
return Response({"exists": False}, status=status.HTTP_200_OK)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even tho a 404 here would explain everything already, I think it is more sensible to respond with 401 unaunthenticated and the message Token has expired or is invalid

try:
account = Account.objects.get(unique_identifier=account_uuid)
except Account.DoesNotExist:
return Response({"error": "Account not found"}, status=status.HTTP_404_NOT_FOUND)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, just return 401 and say the token was invalid

serializer_class = CharacterSerializer

def post(self, request):
server_id = request.data.get("fork_compatibility")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not server id, use fork_compatibility. Even I got confused when reading the code because servers will have a server id eventually, which is to individually identify each of them and this is not it

data_with_extras["fork_compatibility"] = server_id # Enforce fork from token

serializer = self.serializer_class(data=data_with_extras)
serializer.account = account # type: ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happened with the typing here?


# Add fork_compatibility from the token and character_sheet_version from query
query_data = {
"character_sheet_version": self.request.query_params.get("character_sheet_version"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to confirm this was your intention, this means you have to add ?character_sheet_version=v1.0.0 to the URL

except Account.DoesNotExist:
return Response({"error": "Account not found"}, status=status.HTTP_404_NOT_FOUND)

# Try to get character, otherwise create a new one
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this should just patch existing ones. Why create when you have an endpoint for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants