Friday, March 19, 2010

(full) easy authentication, using django.contrib.auth (end)

7. Templates are here, ordered as in urls.py provided in the previous post:

- accounts/base.html
<html>
  <head></head>
  <body>
    {% block content %}
    {% endblock %}
  </body>
</html>


- accounts/login.htnl
{% extends "accounts/base.html" %}

{% block content %}

{% if form.errors %}
<p>Authentication error</p>
{% endif %}

<form action="{% url django.contrib.auth.views.login %}" method="post">
  {% for field in form %}
  <p>
    {{ field.label_tag }}: {{ field }}
    {{ field.errors }}
  </p>
  {% endfor %}
  <p><input type="submit" value="Login" /></p>
  <input type="hidden" name="next" value="{{ next }}" />
</form>

{% endblock %}


- accounts/logged_out.html
{% extends "accounts/base.html" %}

{% block content %}

<p>You have been logged out.</p>
<a href="{% url django.contrib.auth.views.login %}">Login again</a>

{% endblock %}


- accounts/password_change_form.html
{% extends "accounts/base.html" %}

{% block content %}

<form action="" method="post">
  {% for field in form %}
  <p>
    {{ field.label_tag }}: {{ field }}
    {{ field.errors }}
  </p>
  {% endfor %}
  <p><input type="submit" value="Change Password" /></p>
  <input type="hidden" name="next" value="{{ next }}" />
</form>

{% endblock %}


- accounts/password_change_done.html
{% extends "accounts/base.html" %}

{% block content %}

<p>
  Password successfully changed.
</p>

{% endblock %}


- accounts/password_reset_form.html
{% extends "accounts/base.html" %}

{% block content %}

<form action="" method="post">
  {% for field in form %}
  <p>
    {{ field.label_tag }}: {{ field }}
    {{ field.errors }}
  </p>
  {% endfor %}
  <p><input type="submit" value="Reset Password" /></p>
</form>

{% endblock %}


- accounts/password_reset_done.html
{% extends "accounts/base.html" %}

{% block content %}

An email have been sent to you, with the instructions to follow.

{% endblock %}


- accounts/password_reset_confirm.html
{% extends "accounts/base.html" %}

{% block content %}

{% if validlink %}
<form action="" method="post">
  {% for field in form %}
  <p>
    {{ field.label_tag }}: {{ field }}
    {{ field.errors }}
  </p>
  {% endfor %}
  <p><input type="submit" value="Reset password" /></p>
</form>
{% else %}
<p>This link is broken.</p>
{% endif %}

{% endblock %}


- accounts/password_reset_complete.html
{% extends "accounts/base.html" %}

{% block content %}

Password reset done. Thanks.

{% endblock %}


- accounts/password_reset_email.html
{% autoescape off %}

You're receiving this e-mail because you requested a password reset.
Please go to the following page and choose a new password : 
"{{ protocol }}://{{ domain }}{% url django.contrib.auth.views.password_reset_confirm uidb36=uid, token=token %}"

Reminder : your username is {{ user.username }}

Thanks.

{% endautoescape %}


- accounts/signup_form.html
{% extends "accounts/base.html" %}

{% block content %}

<form action="" method="post">
  {% for field in form %}
  <p>
    {{ field.label_tag }}: {{ field }}
    {{ field.errors }}
  </p>
  {% endfor %}
  <p><input type="submit" value="Signup" /></p>
</form>

{% endblock %}


- accounts/signup_done.html
{% extends "accounts/base.html" %}

{% block content %}

A confirmation email have been sent to you, with the instructions to follow.

{% endblock %}


- accounts/signup_complete.html
{% extends "accounts/base.html" %}

{% block content %}

Signup complete. Thanks.

{% endblock %}


- accounts/signup_email.html
{% autoescape off %}

You have received this email because you have requested an account creation.
Please go to the following page to confirm your signing up : 
{{ protocol }}://{{ domain }}{% url mysite.accounts.views.signup_confirm uidb36=uid, token=token %}

Thanks.

{% endautoescape %}


8. That should be all you need. Let me know what you think about this, and if it has helped you. Keep also in mind that :
- an alternative package exist for all this (django-registration)
- I hope that all this will be provided by django in its future releases.

-- Peyman

No comments:

Post a Comment