Forráskód Böngészése

passsword reset views

Roberto Berto 4 éve
szülő
commit
34885ec9bb

+ 2 - 3
vycontrol/accounts/templates/registration/login.html → vycontrol/accounts/templates/accounts/login.html

@@ -23,7 +23,7 @@
     {% endif %}
 {% endif %}
 
-<form method="post" action="{% url 'registration-login' %}">
+<form method="post" action="{% url 'accounts-login' %}">
 {% csrf_token %}
 <table>
 <tr>
@@ -46,8 +46,7 @@
 </form>
 
 <div id="lostpasswd">
-{# Assumes you setup the password_reset view in your URLconf #}
-<p><a href=" url 'vauth-reset' ">Lost password?</a></p>
+<p><a href="{% url 'reset_password' %}">Lost password?</a></p>
 </div>
 
 

+ 1 - 1
vycontrol/accounts/templates/registration/logged_out.html → vycontrol/accounts/templates/accounts/logout.html

@@ -10,7 +10,7 @@
 
 <p>
 You're logged out. 
-<p><a href="{% url 'registration-login' %}">Log-in again</a>.
+<p><a href="{% url 'accounts-login' %}">Log-in again</a>.
 </p>
 
 {% endblock %}

+ 54 - 0
vycontrol/accounts/templates/accounts/lost.html

@@ -0,0 +1,54 @@
+{% extends "base_not_logged.html" %}
+
+{% block header_title %}Login{% endblock %}
+{% block section_title %}Login{% endblock %}
+
+{% block debug %}
+{% endblock %}
+
+
+{% block content %}
+
+
+{% if form.errors %}
+<p>Your username and password didn't match. Please try again.</p>
+{% endif %}
+
+{% if next %}
+    {% if user.is_authenticated %}
+    <p>Your account doesn't have access to this page. To proceed,
+    please login with an account that has access. Or <a href="/">login to start page</a>.</p>
+    {% else %}
+    <p>Please login to see this page.</p>
+    {% endif %}
+{% endif %}
+
+<form method="post" action="{% url 'accounts-login' %}">
+{% csrf_token %}
+<table>
+<tr>
+    <td>{{ form.username.label_tag }}</td>
+    <td>{{ form.username }}</td>
+</tr>
+<tr>
+    <td>{{ form.password.label_tag }}</td>
+    <td>{{ form.password }}</td>
+</tr>
+</table>
+
+<input type="submit" value="login">
+
+    
+<input type="hidden" name="next" value="{% if next %}{{ next }}{% else %}{% url 'interface:interface-list' %}{% endif %}">
+
+
+    
+</form>
+
+<div id="lostpasswd">
+{# Assumes you setup the password_reset view in your URLconf #}
+<p><a href=" url 'vauth-reset' ">Lost password?</a></p>
+</div>
+
+
+{% endblock %}

+ 24 - 0
vycontrol/accounts/templates/accounts/password_reset.html

@@ -0,0 +1,24 @@
+{% extends "base_not_logged.html" %}
+{% block header_title %}Password Reset{% endblock %}
+{% block section_title %}Password Reset{% endblock %}
+
+{% block debug %}
+{% endblock %}
+
+
+
+{% block content %}
+
+
+<form action="" method="POST" class="text-center">
+  {% csrf_token %}
+  {{form}}
+  <input type="submit" value="Send email" /><br>
+</form><br/>
+
+
+<div class="text-center">
+  <a href="{% url 'accounts-login' %}">Return to login page</a>
+</div>
+
+{% endblock%}

+ 19 - 0
vycontrol/accounts/templates/accounts/password_reset_complete.html

@@ -0,0 +1,19 @@
+{% extends "base_not_logged.html" %}
+{% block header_title %}Password Reset complete{% endblock %}
+{% block section_title %}Password Reset complete{% endblock %}
+
+{% block debug %}
+{% endblock %}
+
+{% block content%}
+<p>
+    Your Password has been set. You may go ahead and login
+</p>
+
+
+<div class="text-center">
+    <a href="{% url 'accounts-login' %}">Return to login page</a>
+</div>
+
+
+{% endblock%}

+ 10 - 0
vycontrol/accounts/templates/accounts/password_reset_email.html

@@ -0,0 +1,10 @@
+{% autoescape off %}
+To initiate the password reset process for your {{ user.get_username }} VyControl Account,
+click the link below:
+
+{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
+
+If clicking the link above doesn't work, please copy and paste the URL in a new browser
+window instead.
+
+{% endautoescape %}

+ 20 - 0
vycontrol/accounts/templates/accounts/password_reset_sent.html

@@ -0,0 +1,20 @@
+{% extends "base_not_logged.html" %}
+{% block header_title %}Password Reset{% endblock %}
+{% block section_title %}Password Reset{% endblock %}
+
+{% block debug %}
+{% endblock %}
+
+
+
+{% block content%}
+
+<p>We’ve emailed you instructions for setting your password, if an account exists with the email you entered. You should receive them shortly.</p>
+<p>If you don’t receive an email, please make sure you’ve entered the address you registered with, and check your spam folder.</p>
+
+
+
+<div class="text-center">
+  <a href="{% url 'accounts-login' %}">Return to login page</a>
+</div>
+{% endblock%}

+ 1 - 0
vycontrol/accounts/templates/accounts/password_reset_subject.txt

@@ -0,0 +1 @@
+VyControl password reset

+ 18 - 0
vycontrol/accounts/templates/accounts/password_reset_token.html

@@ -0,0 +1,18 @@
+{% extends "base_not_logged.html" %}
+{% block header_title %}Change your password{% endblock %}
+{% block section_title %}Change your password{% endblock %}
+
+{% block debug %}
+{% endblock %}
+
+
+
+{% block content%}
+<form action="" method="POST">
+  {% csrf_token %} 
+  {{form}}
+  <input type="submit" value="Reset Password"/>
+</form>
+
+
+{% endblock%}

+ 0 - 0
vycontrol/accounts/templates/registration/start.html → vycontrol/accounts/templates/accounts/start.html


+ 2 - 2
vycontrol/accounts/views.py

@@ -25,13 +25,13 @@ def index(request):
         if request.user.is_authenticated:
             return redirect('interface:interface-list')
         else:
-            return redirect('registration-login')
+            return redirect('accounts-login')
     else:
         if 'username' in request.POST and 'password' in request.POST:
             user = User.objects.create_superuser(username=request.POST['username'], email='', password=request.POST['password'])
             user.save()
             return redirect('%s?next=%s' % (reverse('registration-login'), '/config/instance-add'))
-    template = loader.get_template('registration/start.html')
+    template = loader.get_template('accounts/start.html')
     context = { 
         'users_admin': users_admin.all()
     }   

+ 2 - 13
vycontrol/vycontrol/templates/base.html

@@ -46,7 +46,7 @@
               </select>
             
 
-              <span id="menu-username">{% block username %}{% endblock %}</span> <span id="vycontrol-config-menu"> <a href="{% url 'registration-logout' %}">Logout</a></span>
+              <span id="menu-username">{% block username %}{% endblock %}</span> <span id="vycontrol-config-menu"> <a href="{% url 'accounts-logout' %}">Logout</a></span>
 
 
           </p>
@@ -72,18 +72,7 @@
     <li><a href="{% url 'static:static-list' %}">Static Routing</a></li>
     <li><a href="{% url 'ntp:ntp-list' %}">NTP</a></li>
 
-    <!-- 
-    <li><a href="{% url 'arp:arp-list' %}">ARP</a></li>
-    <li><a href="{% url 'ospf:ospf-list' %}">OSPF</a></li>
-    <li><a href="{% url 'bgp:bgp-list' %}">BGP</a></li>
-    <li><a href="{% url 'dhcp:dhcp-list' %}">DHCP</a></li>
-    <li><a href="{% url 'ssh:ssh-list' %}">SSH</a></li>
-    <li><a href="{% url 'openvpn:openvpn-list' %}">OpenVPN</a></li>
-    <li><a href="{% url 'ipsec:ipsec-list' %}">IPSEC</a></li>
-    <li><a href="{% url 'nat:nat-list' %}">NAT</a></li>
-    <li><a href="{% url 'qos:qos-list' %}">QoS</a></li>
-    <li><a href="{% url 'wanlb:wanlb-list' %}">Wan Load Balancing</a></li>
-    -->
+
   </ul>
 
 

+ 1 - 1
vycontrol/vycontrol/templates/base_not_logged.html

@@ -32,7 +32,7 @@
 
             
 
-              <span id="vycontrol-config-menu"><a href="{% url 'registration-login' %}">Login</a></span>
+              <span id="vycontrol-config-menu"><a href="{% url 'accounts-login' %}">Login</a></span>
 
           </p>
         </div>

+ 0 - 17
vycontrol/vycontrol/templates/vycontrol/vycontrol_login.html

@@ -1,17 +0,0 @@
-{% extends "base.html" %}
-
-{% block header_title %}Login{% endblock %}
-{% block section_title %}Login{% endblock %}
-
-{% block content %}
-
-<p>Auth not yet implemented. </p>
-
-<ul>
-    <li>First time? <a href="{% url 'config:instance-add' %}">create a new instance</a>.</p></li>
-    <li>Proceed to <a href="{% url 'config:instances' %}">list os instances</a>.</p></li>
-</ul>
-
-
-
-{% endblock %}

+ 18 - 13
vycontrol/vycontrol/urls.py

@@ -27,6 +27,8 @@ import pprint
 from . import views
 
 from django.contrib.auth import views as auth_views
+from django.urls import path, re_path
+
 
 
 app_name = 'vycontrol'
@@ -38,24 +40,27 @@ urlpatterns = [
     #path('', views.vycontrol_login, name='vycontrol-login'),
     path('admin/', admin.site.urls, name="django-admin"),
     #path('change-password/', auth_views.PasswordChangeView.as_view()),
-    path('login/', auth_views.LoginView.as_view(), name="registration-login"),
-    path('logout/', auth_views.LogoutView.as_view(), name="registration-logout"),
+    path('login/', auth_views.LoginView.as_view(template_name='accounts/login.html'), name="accounts-login"),
+    path('logout/', auth_views.LogoutView.as_view(template_name='accounts/logout.html'), name="accounts-logout"),
+    path('password_reset/', auth_views.PasswordResetView.as_view(template_name = 'accounts/password_reset.html'), name ='reset_password'),
+    path('password_reset_sent/', auth_views.PasswordResetDoneView.as_view(template_name = 'accounts/password_reset_sent.html'), name ='password_reset_done'),
+    path('password_reset_token/<uidb64>/<token>', auth_views.PasswordResetConfirmView.as_view(template_name = 'accounts/password_reset_token.html'), name ='password_reset_confirm'),
+    path('password_reset_complete/', auth_views.PasswordResetCompleteView.as_view(template_name = 'accounts/password_reset_complete.html'), name ='password_reset_complete'),
 
 
 
     path('interface/', include('interface.urls')),
-
-    path('arp/', include('arp.urls')),
-    path('bgp/', include('bgp.urls')),
-    path('dhcp/', include('dhcp.urls')),
+    #path('arp/', include('arp.urls')),
+    #path('bgp/', include('bgp.urls')),
+    #path('dhcp/', include('dhcp.urls')),
     path('firewall/', include('firewall.urls')),
-    path('ipsec/', include('ipsec.urls')),
-    path('nat/', include('nat.urls')),
+    #path('ipsec/', include('ipsec.urls')),
+    #path('nat/', include('nat.urls')),
     path('ntp/', include('ntp.urls')),
-    path('openvpn/', include('openvpn.urls')),
-    path('ospf/', include('ospf.urls')),
-    path('qos/', include('qos.urls')),
-    path('ssh/', include('ssh.urls')),
+    #path('openvpn/', include('openvpn.urls')),
+    #path('ospf/', include('ospf.urls')),
+    #path('qos/', include('qos.urls')),
+    #path('ssh/', include('ssh.urls')),
     path('static/', include('static.urls')),
-    path('wanlb/', include('wanlb.urls')),
+    #path('wanlb/', include('wanlb.urls')),
 ]

+ 1 - 1
vycontrol/vycontrol/views.py

@@ -9,7 +9,7 @@ from config.models import Instance
 
 def vycontrol_login(request):
     
-    template = loader.get_template('vycontrol/vycontrol_login.html')
+    template = loader.get_template('login.html')
     context = {
     }
     return HttpResponse(template.render(context, request))