[OCaml] High Intensity Training Online
fix Hide nav before sign-in
Show primary navigation only after Dream authenticates the trainee.
Changed files
lib/web/pages.ml
@@ -41,6 +41,21 @@
41
41
]
42
42
| _ -> []
43
43
in
44
Added:
let primary_nav =
45
Added:
match (trainee, request) with
46
Added:
| Some _, Some _ ->
47
Added:
[
48
Added:
tag "nav"
49
Added:
[ class_ "primary-nav" ]
50
Added:
[
51
Added:
nav_link Routes.home "Overview";
52
Added:
nav_link Routes.routine "Routine";
53
Added:
nav_link Routes.workout "Current workout";
54
Added:
nav_link Routes.history "History";
55
Added:
];
56
Added:
]
57
Added:
| _ -> []
58
Added:
in
44
59
let mobile_middle =
45
60
if workout_in_progress then nav_link Routes.workout "Current Workout"
46
61
else nav_link Routes.routine "Routine"
@@ -80,16 +95,8 @@
80
95
[ txt "High Intensity Tracker Online" ];
81
96
];
82
97
];
83
Removed:
tag "nav"
84
Removed:
[ class_ "primary-nav" ]
85
Removed:
[
86
Removed:
nav_link Routes.home "Overview";
87
Removed:
nav_link Routes.routine "Routine";
88
Removed:
nav_link Routes.workout "Current workout";
89
Removed:
nav_link Routes.history "History";
90
Removed:
];
91
98
]
92
Removed:
@ account_area);
99
Added:
@ primary_nav @ account_area);
93
100
tag "main" [] [ tag "div" [ class_ "page-surface" ] content ];
94
101
];
95
102
tag "nav"
test/test_web.ml
@@ -114,7 +114,7 @@
114
114
let page = body (get client "/register") in
115
115
let token = Option.get (csrf_token page) in
116
116
post client "/register"
117
Removed:
[("dream.csrf", token); ("username", username); ("password", password)]
117
Added:
[ ("dream.csrf", token); ("username", username); ("password", password) ]
118
118
119
119
let sign_in_new client =
120
120
register client ~username:"lifter" ~password:"heavyduty1"
@@ -154,7 +154,10 @@
154
154
(contains ~substring:"Routines" (body overview));
155
155
Alcotest.(check bool)
156
156
"shows the signed-in username" true
157
Removed:
(contains ~substring:"lifter" (body overview)) );
157
Added:
(contains ~substring:"lifter" (body overview));
158
Added:
Alcotest.(check bool)
159
Added:
"shows primary navigation" true
160
Added:
(contains ~substring:"primary-nav" (body overview)) );
158
161
( "the sign-in page renders a username field",
159
162
`Quick,
160
163
fun () ->
@@ -163,6 +166,14 @@
163
166
Alcotest.(check bool)
164
167
"has a username field" true
165
168
(contains ~substring:"name=\"username\"" page) );
169
Added:
( "auth pages omit the primary navigation",
170
Added:
`Quick,
171
Added:
fun () ->
172
Added:
let c = client () in
173
Added:
let page = body (get c "/register") in
174
Added:
Alcotest.(check bool)
175
Added:
"no primary navigation" false
176
Added:
(contains ~substring:"primary-nav" page) );
166
177
( "a form post without a CSRF token is refused",
167
178
`Quick,
168
179
fun () ->