django-rest-framework-passwordless
django-rest-framework-passwordless copied to clipboard
There is no demo credentials to test the login
I previously integrated ios app with django passwordless. On submiting the app for review they are asking a demo account from which they can login without having to enter the six digit code. is there any way to create demo credentials for mobile login with phone number and a fixed 6 digit code?
Interesting– any ideas for how we should handle this in a sane way?
I added this for this exact purpose: https://github.com/charleshan/django-rest-framework-passwordless/commits/master
There's definitely room for improvement. I just added enough to pass the review process (e.g. The password is hardcoded 😂)
i hit the same issue with app store reviews. until one of the proposed PRs gets merged, i'm hacking/working around it with a signal:
@receiver(signals.pre_save, sender=passwordless.CallbackToken)
def update_demo_account_token(sender, instance, **kwargs):
"""
Intercept and update demo account's login token to a constant value.
"""
demo_token = settings.DEMO_TOKEN_VALUE
auth_type = passwordless.CallbackToken.TOKEN_TYPE_AUTH
# check for callback token creation for the demo account
if instance.user.email != settings.DEMO_USER_EMAIL or instance.type != auth_type or not instance.is_active:
return
# tokens can only be used once so we need to delete it from the db
if passwordless.CallbackToken.objects.filter(key=demo_token, type=auth_type).exists():
passwordless.CallbackToken.objects.filter(key=demo_token, type=auth_type).delete()
instance.key = demo_token