-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a password reset token apiview and a signal for it
- Loading branch information
1 parent
2b7d549
commit 959605d
Showing
8 changed files
with
154 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
""" contains basic admin views for MultiToken """ | ||
from django.contrib import admin | ||
from django_rest_multitokenauth.models import MultiToken | ||
from django_rest_multitokenauth.models import MultiToken, ResetPasswordToken | ||
|
||
|
||
@admin.register(MultiToken) | ||
class MultiTokenAdmin(admin.ModelAdmin): | ||
list_display = ('user', 'key', 'user_agent') | ||
|
||
|
||
@admin.register(ResetPasswordToken) | ||
class ResetPasswordTokenAdmin(admin.ModelAdmin): | ||
list_display = ('user', 'key', 'created_at', 'ip_address', 'user_agent') |
32 changes: 32 additions & 0 deletions
32
django_rest_multitokenauth/migrations/0003_resetpasswordtoken.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.10.5 on 2017-01-18 15:30 | ||
from __future__ import unicode_literals | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('django_rest_multitokenauth', '0002_rename_ip_address_20160426'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='ResetPasswordToken', | ||
fields=[ | ||
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='When was this token generated')), | ||
('key', models.CharField(max_length=64, primary_key=True, serialize=False, verbose_name='Key')), | ||
('ip_address', models.GenericIPAddressField(default='127.0.0.1', verbose_name='The IP address of this session')), | ||
('user_agent', models.CharField(default='', max_length=256, verbose_name='HTTP User Agent')), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='password_reset_tokens', to=settings.AUTH_USER_MODEL, verbose_name='The User which is associated to this password reset token')), | ||
], | ||
options={ | ||
'verbose_name': 'Password Reset Token', | ||
'verbose_name_plural': 'Password Reset Tokens', | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from rest_framework import serializers | ||
|
||
|
||
class EmailSerializer(serializers.Serializer): | ||
email = serializers.EmailField() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import django.dispatch | ||
|
||
reset_password_token_created = django.dispatch.Signal(providing_args=["reset_password_token"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
""" URL Configuration for core auth | ||
""" | ||
from django.conf.urls import url, include | ||
from django_rest_multitokenauth.views import login_and_obtain_auth_token, logout_and_delete_auth_token | ||
from django_rest_multitokenauth.views import login_and_obtain_auth_token, logout_and_delete_auth_token, reset_password_request_token, reset_password_confirm | ||
|
||
urlpatterns = [ | ||
url(r'^login', login_and_obtain_auth_token), # normal login with session | ||
url(r'^logout', logout_and_delete_auth_token), | ||
url(r'^reset_password', reset_password_request_token), | ||
url(r'^reset_password/confirm', reset_password_confirm) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters