0
votes

The application is using Django backend and ReactJS frontend. I created user accounts using the standard rest-auth package in Django, calling the endpoints from the ReactJS frontend forms.

Sign up and login works fine, but when it comes to e-mail confirmation, I haven't been able to find where confirmation keys are stored and how this is accessed. I've overridden get_email_confirmation_url from DefaultAccountAdapter to change the URL confirmation link that is being sent out from [backend]/rest-auth/registration/account-confirm-email/[KEY] to [frontend]/registration/confirm-email/[KEY].

I'm able to read out [KEY] at the frontend. However, how do I retrieve the e-mailaddress and name of the user that's trying to confirm their address? In the standard Django template this is possible (email_confirm.html):

{% extends "account/base.html" %}

{% load i18n %}
{% load account %}

{% block head_title %}{% trans "Confirm E-mail Address" %}{% endblock %}


{% block content %}
<h1>{% trans "Confirm E-mail Address" %}</h1>

{% if confirmation %}

{% user_display confirmation.email_address.user as user_display %}

<p>{% blocktrans with confirmation.email_address.email as email %}Please confirm that <a href="mailto:{{ email }}">{{ email }}</a> is an e-mail address for user {{ user_display }}.{% endblocktrans %}</p>

<form method="post" action="{% url 'account_confirm_email' confirmation.key %}">
{% csrf_token %}
    <button type="submit">{% trans 'Confirm' %}</button>
</form>

{% else %}

{% url 'account_email' as email_url %}

<p>{% blocktrans %}This e-mail confirmation link expired or is invalid. Please <a href="{{ email_url }}">issue a new e-mail confirmation request</a>.{% endblocktrans %}</p>

{% endif %}

{% endblock %}

Where does the information from confirmation.email_address.user and confirmation.email_address.email come from? The account_emailconfirmation table is empty and account_emailaddress only contains a boolean saying whether the emailaccount is verified or not, but no confirmation key.

1

1 Answers

0
votes

Keys are no longer stored https://stackoverflow.com/a/41364419/3241374

I use url confirmation:

  1. I grab the key on the front end
  2. Post it to the backend confirmation url
  3. Check the response / login user

Good starting point is this answer: https://stackoverflow.com/a/59327408/3241374