Holger Frey
7 years ago
10 changed files with 261 additions and 13 deletions
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
{% extends "ordr2:templates/layout.jinja2" %} |
||||
|
||||
{% block title %} Ordr | Reset Password {% endblock title %} |
||||
|
||||
{% block content %} |
||||
<div class="row"> |
||||
<div class="col-2"></div> |
||||
<div class="col-5"> |
||||
|
||||
<h1>Password Reset Successful</h1> |
||||
<p>You can now log on with your new password</p> |
||||
|
||||
<form action="{{ request.resource_url(request.root, 'account', 'login') }}" method="POST" id="login-form"> |
||||
<input type="hidden" name="csrf_token" value="{{ get_csrf_token() }}"> |
||||
<div class="form-group row"> |
||||
<label for="username" class="col-2">Username</label> |
||||
<div class="col-6"> |
||||
<input name="username" id="username" type="text" class="form-control"> |
||||
</div> |
||||
</div> |
||||
<div class="form-group row"> |
||||
<label for="password" class="col-2">Password</label> |
||||
<div class="col-6"> |
||||
<input name="password" id="password>" type="password" class="form-control"> |
||||
</div> |
||||
</div> |
||||
<div class="form-group row"> |
||||
<div class="col-2"></div> |
||||
<div class="col-6"> |
||||
<button type="submit" class="btn btn-sm btn-primary">Log in</button> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
|
||||
</div> |
||||
</div> |
||||
{% endblock content %} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
{% extends "ordr2:templates/layout.jinja2" %} |
||||
|
||||
{% block title %} Ordr | Reset Password {% endblock title %} |
||||
|
||||
{% block content %} |
||||
<div class="row"> |
||||
<div class="col-2"></div> |
||||
<div class="col-5"> |
||||
|
||||
<h1>Reset Your Password</h1> |
||||
{{ form.render()|safe }} |
||||
|
||||
</div> |
||||
</div> |
||||
{% endblock content %} |
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
||||
<title>[ordr] reset your password</title> |
||||
<link href='http://fonts.googleapis.com/css?family=Anton&subset=latin,latin-ext' rel='stylesheet' type='text/css'> |
||||
</head> |
||||
<body> |
||||
<h1>Hi there!</h1> |
||||
<p> |
||||
To set a new password for the account "{{ user.user_name }}" follow this link |
||||
<a href="{{ request.resource_url(context, data.token.hash) }}">{{ request.resource_url(context, data.token.hash) }}</a> |
||||
</p> |
||||
<p> The link will expire on {{ data.token.expires.strftime('%d.%m.%y at %H:%M') }}. |
||||
<p class="signature"> |
||||
Regards, |
||||
<br/> |
||||
<span class="brand">ordr</span> |
||||
</p> |
||||
<p class="footprint"> |
||||
<small>Please don't respont to this email! This is an automatically generated notification by the system.</small> |
||||
<a href="http://distractedbysquirrels.com/" target="_blank" title="This software was originally written by Sebastian Sebald." class="icon-dbs"></a> |
||||
</p> |
||||
</body> |
||||
</html> |
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
''' tests for the login, logout, registration and account settings''' |
||||
|
||||
import pytest |
||||
|
||||
from pyramid_mailer import get_mailer |
||||
|
||||
from . import testapp, get_token_url |
||||
from .. import get_user |
||||
|
||||
|
||||
@pytest.mark.xfail |
||||
def test_reset_password(testapp): |
||||
''' test the complete reset password process ''' |
||||
|
||||
# submit the registration form |
||||
response = testapp.get('/account/forgot-password') |
||||
form = response.forms[1] |
||||
form['username_or_email'] = 'TerryGilliam' |
||||
response = form.submit() |
||||
assert response.location == 'http://localhost/account/forgot-password-email' |
||||
|
||||
response = response.follow() |
||||
assert 'Password Reset Link' in response |
||||
|
||||
# click the email verification token |
||||
mailer = get_mailer(testapp.app.registry) |
||||
email = mailer.outbox[-1] |
||||
assert email.subject == '[ordr] Password Reset' |
||||
|
||||
token_link = get_token_url(email) |
||||
response = testapp.get(token_link) |
||||
form = response.forms[1] |
||||
form['password'] = 'Nudge Nudge' |
||||
form['password-confirm'] = 'Nudge Nudge' |
||||
response = form.submit() |
||||
assert response.location == 'http://localhost/account/login' |
||||
|
||||
response = response.follow() |
||||
assert 'consider a longer password' in response |
||||
assert 'Your password was changed' in response |
||||
|
||||
form = response.forms[1] |
||||
form['username'] = 'TerryGilliam' |
||||
form['password'] = 'Nudge Nudge' |
||||
response = form.submit().follow() |
||||
assert '<!-- user is logged in -->' in response |
||||
|
||||
|
||||
|
||||
|
Reference in new issue