Pārlūkot izejas kodu

Make logout a post

master
Dylan Baker 3 gadus atpakaļ
vecāks
revīzija
775438598c
3 mainītis faili ar 19 papildinājumiem un 13 dzēšanām
  1. 1
    1
      src/main.rs
  2. 1
    1
      templates/index.html
  3. 17
    11
      templates/layout.html

+ 1
- 1
src/main.rs Parādīt failu

176
         });
176
         });
177
 
177
 
178
     app.at("/logout")
178
     app.at("/logout")
179
-        .get(|mut req: tide::Request<()>| async move {
179
+        .post(|mut req: tide::Request<()>| async move {
180
             req.session_mut().remove("logged_in");
180
             req.session_mut().remove("logged_in");
181
             req.session_mut().insert("logged_in", false)?;
181
             req.session_mut().insert("logged_in", false)?;
182
             Ok(tide::Redirect::new("/"))
182
             Ok(tide::Redirect::new("/"))

+ 1
- 1
templates/index.html Parādīt failu

12
     <textarea class="form__textarea" name="body" required></textarea>
12
     <textarea class="form__textarea" name="body" required></textarea>
13
   </div>
13
   </div>
14
   <div class="form__field">
14
   <div class="form__field">
15
-    <input class="form__button" type="submit" value="Post" />
15
+    <input class="btn" type="submit" value="Post" />
16
   </div>
16
   </div>
17
 </form>
17
 </form>
18
 {% endif %}
18
 {% endif %}

+ 17
- 11
templates/layout.html Parādīt failu

27
         text-decoration: none;
27
         text-decoration: none;
28
       }
28
       }
29
 
29
 
30
-      .header,
30
+      .btn {
31
+        cursor: pointer;
32
+        padding: 0.15em 0.3em;
33
+      }
34
+
31
       .container {
35
       .container {
32
         margin: auto;
36
         margin: auto;
33
         max-width: 800px;
37
         max-width: 800px;
34
         padding: 1em;
38
         padding: 1em;
35
       }
39
       }
36
 
40
 
41
+      .header {
42
+        margin: 1em 0;
43
+      }
44
+
37
       .form__field {
45
       .form__field {
38
         margin: 1em 0;
46
         margin: 1em 0;
39
       }
47
       }
56
         resize: vertical;
64
         resize: vertical;
57
       }
65
       }
58
 
66
 
59
-      .form__button {
60
-        padding: 0.25em 1em;
61
-      }
62
-
63
-      .post {
67
+      .post:not(:last-child) {
64
         margin: 3em 0;
68
         margin: 3em 0;
65
       }
69
       }
66
 
70
 
111
     </style>
115
     </style>
112
   </head>
116
   </head>
113
   <body>
117
   <body>
114
-    <header class="header">
115
-      {% if logged_in %}
116
-      <a href="/logout">logout</a>
117
-      {% endif %}
118
-    </header>
119
     <div class="container">
118
     <div class="container">
119
+      <header class="header">
120
+        {% if logged_in %}
121
+        <form action="/logout" method="POST">
122
+          <input class="btn" type="submit" value="Log out" />
123
+        </form>
124
+        {% endif %}
125
+      </header>
120
       {% block content %} {% endblock %}
126
       {% block content %} {% endblock %}
121
     </div>
127
     </div>
122
   </body>
128
   </body>

Notiek ielāde…
Atcelt
Saglabāt