Skip to content

Commit ac9c85e

Browse files
committed
start on 18
1 parent c126ef9 commit ac9c85e

File tree

5 files changed

+46
-65
lines changed

5 files changed

+46
-65
lines changed

chapter_16_javascript.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,13 @@ TIP: I like to keep helper methods in the FT class that's using them,
177177
It stops the base class from getting too cluttered. YAGNI.
178178

179179

180+
[[js-spike]]
180181
=== A Quick "Spike"
181182

183+
((("spike")))
184+
((("exploratory coding", see="also spiking and de-spiking")))
185+
((("spiking and de-spiking", "defined")))
186+
((("prototyping", see="spiking and de-spiking")))
182187
This will be our first bit of JavaScript.
183188
We're also interacting with the Bootstrap CSS framework,
184189
which we maybe don't know very well.

chapter_18_spiking_custom_auth.asciidoc

Lines changed: 39 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
[[chapter_18_spiking_custom_auth]]
2-
User Authentication, Spiking, and [keep-together]#De-Spiking#
3-
-------------------------------------------------------------
2+
== User Authentication, Spiking, and [keep-together]#De-Spiking#
43

54

6-
7-
((("authentication", id="Adespike18")))Our
8-
beautiful lists site has been live for a few days, and our users are
5+
((("authentication", id="Adespike18")))
6+
Our beautiful lists site has been live for a few days, and our users are
97
starting to come back to us with feedback. "We love the site", they say, "but
108
we keep losing our lists. Manually remembering URLs is hard. It'd be great if
119
it could remember what lists we'd started".
@@ -18,8 +16,8 @@ to try out?
1816
Clearly the requirement here is that people want to have some kind of user
1917
account on the site. So, without further ado, let's dive into authentication.
2018

21-
((("passwords")))Naturally
22-
we're not going to mess about with remembering passwords
19+
((("passwords")))
20+
Naturally we're not going to mess about with remembering passwords
2321
ourselves--besides being 'so' '90s, secure storage of user passwords is a
2422
security nightmare we'd rather leave to someone else. We'll use something
2523
fun called passwordless auth instead.
@@ -30,13 +28,13 @@ leave it to you to discover on your own.)
3028

3129

3230
[role="pagebreak-before less_space"]
33-
Passwordless Auth
34-
~~~~~~~~~~~~~~~~~
35-
31+
=== Passwordless Auth
3632

3733

38-
((("authentication", "passwordless")))((("Oauth")))((("Openid")))What
39-
authentication system could we use to avoid storing passwords ourselves?
34+
((("authentication", "passwordless")))
35+
((("Oauth")))
36+
((("Openid")))
37+
What authentication system could we use to avoid storing passwords ourselves?
4038
Oauth? Openid? "Login with Facebook"? Ugh. For me those all have
4139
unacceptable creepy overtones; why should Google or Facebook know what sites
4240
you're logging into and when?
@@ -67,30 +65,7 @@ a production website, but this is just a fun toy project so let's give it a go.
6765

6866

6967

70-
Exploratory Coding, aka "Spiking"
71-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72-
73-
TODO: I have copied this paragraph into <<chapter_16_javascript>> so it's now
74-
a duplicate.
75-
76-
77-
((("exploratory coding", see="also spiking and de-spiking")))((("spiking and de-spiking", "defined")))((("prototyping", see="spiking and de-spiking")))Before
78-
I wrote this chapter all I knew about passwordless auth was the outline
79-
I'd read in the article linked above. I'd never seen any code for it, and didn't really know where
80-
to start in building it.
81-
82-
In pass:[Chapters <a data-type="xref" href="#chapter_13_database_layer_validation" data-xrefstyle="select:labelnumber">#chapter_13_database_layer_validation</a> and <a data-type="xref" href="#chapter_14_simple_form" data-xrefstyle="select:labelnumber">#chapter_14_simple_form</a>] we saw that you
83-
can use a unit test as a way of exploring a new API or tool, but sometimes you
84-
just want to hack something together without any
85-
tests at all, just to see if it works, to learn it or get a feel for it.
86-
That's absolutely fine. When learning a new tool or exploring a new possible
87-
solution, it's often appropriate to leave the rigorous TDD process to one side,
88-
and build a little prototype without tests, or perhaps with very few tests.
89-
The goat doesn't mind looking the other way for a bit.
90-
91-
This kind of prototyping activity is often called a "spike", for
92-
http://stackoverflow.com/questions/249969/why-are-tdd-spikes-called-spikes[reasons
93-
best known].
68+
=== Another Spike
9469

9570
((("django-allauth")))((("python-social-auth")))The
9671
first thing I did was take a look at existing Python and Django authentication
@@ -110,13 +85,16 @@ yourself that it really does work.
11085

11186

11287

113-
Starting a Branch for the Spike
114-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88+
==== Starting a Branch for the Spike
89+
90+
((("spiking and de-spiking", "branching your VCS")))
91+
((("Git", "creating branches")))
92+
This spike is going to be a bit more involved that the last one,
93+
so we'll be a little more rigorous with our version control.
11594

116-
((("spiking and de-spiking", "branching your VCS")))((("Git", "creating branches")))Before
117-
embarking on a spike, it's a good idea to start a new branch, so you
118-
can still use your VCS without worrying about your spike commits getting mixed
119-
up with your production code:
95+
Before embarking on a spike it's a good idea to start a new branch,
96+
so you can still use your VCS without worrying about
97+
your spike commits getting mixed up with your production code:
12098

12199
[subs="specialcharacters,quotes"]
122100
----
@@ -135,8 +113,7 @@ spike:
135113
*****
136114

137115

138-
Frontend Log in UI
139-
^^^^^^^^^^^^^^^^^^
116+
==== Frontend Log in UI
140117

141118

142119
((("authentication", "frontend log in UI")))Let's
@@ -145,27 +122,27 @@ enter your email address into the navbar, and a logout link for
145122
users who are already authenticated:
146123

147124
[role="sourcecode"]
148-
.lists/templates/base.html (ch16l001)
125+
.lists/templates/base.html (ch18l001)
149126
====
150127
[source,html]
151128
----
152-
<body>
153-
<div class="container">
154-
155-
<div class="navbar">
156-
{% if user.is_authenticated %}
157-
<p>Logged in as {{ user.email }}</p>
158-
<p><a id="id_logout" href="{% url 'logout' %}">Log out</a></p>
159-
{% else %}
160-
<form method="POST" action ="{% url 'send_login_email' %}">
161-
Enter email to log in: <input name="email" type="text" />
162-
{% csrf_token %}
163-
</form>
164-
{% endif %}
165-
</div>
166-
167-
<div class="row">
168-
[...]
129+
<body>
130+
<div class="container">
131+
132+
<div class="navbar">
133+
{% if user.is_authenticated %}
134+
<p>Logged in as {{ user.email }}</p>
135+
<p><a id="id_logout" href="{% url 'logout' %}">Log out</a></p>
136+
{% else %}
137+
<form method="POST" action ="">
138+
Enter email to log in: <input name="email" type="text" />
139+
{% csrf_token %}
140+
</form>
141+
{% endif %}
142+
</div>
143+
144+
<div class="row justify-content-center p-5 bg-body-tertiary rounded-3">
145+
[...]
169146
----
170147
====
171148

Submodule superlists updated 130 files

tests/test_chapter_14_simple_form.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
import unittest
43

54
from book_tester import ChapterTest

0 commit comments

Comments
 (0)