django-rest-framework-passwordless icon indicating copy to clipboard operation
django-rest-framework-passwordless copied to clipboard

There is no demo credentials to test the login

Open divergentsigns opened this issue 4 years ago • 3 comments

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?

divergentsigns avatar Jan 25 '20 22:01 divergentsigns

Interesting– any ideas for how we should handle this in a sane way?

aaronn avatar Feb 06 '20 21:02 aaronn

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 😂)

charleshan avatar Mar 07 '20 23:03 charleshan

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

jws avatar Apr 17 '20 06:04 jws