Adding route for login and login_form
The EmptyContext is probably dumb or at least goofy.. but I can't work out a better way of making render() happy right now.
This commit is contained in:
		
							parent
							
								
									fd1479edcd
								
							
						
					
					
						commit
						9eaf121454
					
				
							
								
								
									
										11
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/main.rs
									
									
									
									
									
								
							| @ -109,6 +109,16 @@ struct LoginData { | |||||||
|     password: String, |     password: String, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #[derive(Serialize)] | ||||||
|  | struct EmptyContext { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #[get("/login")] | ||||||
|  | fn login_form() -> Template { | ||||||
|  |     let context = EmptyContext {}; | ||||||
|  |     Template::render("login_form", &context) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| #[post("/login", data = "<form_data>")] | #[post("/login", data = "<form_data>")] | ||||||
| fn login(form_data: Form<LoginData>) -> String { | fn login(form_data: Form<LoginData>) -> String { | ||||||
|     let auth = BasicAuthentication { |     let auth = BasicAuthentication { | ||||||
| @ -188,6 +198,7 @@ fn routes() -> Vec<rocket::Route> { | |||||||
|         oidc_config, |         oidc_config, | ||||||
|         get_keys, |         get_keys, | ||||||
|         login, |         login, | ||||||
|  |         login_form, | ||||||
|     ] |     ] | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,23 +1,6 @@ | |||||||
| {% extends "base" %} | {% extends "base" %} | ||||||
| 
 | 
 | ||||||
| {% block content %} | {% block content %} | ||||||
|     <h1>Login</h1> |     <h1>Hello?</h1> | ||||||
|     <form action="/login" method="POST"> |     <a href="/login">Login</a> | ||||||
|         <fieldset> |  | ||||||
|             <legend>Login</legend> |  | ||||||
|             <div class="form-group"> |  | ||||||
|                 <label for="username">Username:</label> |  | ||||||
|                 <input type="text" name="username"> |  | ||||||
|                 <label for="username"><abbr title="required" aria-label="required">*</abbr></label> |  | ||||||
|             </div> |  | ||||||
|             <div class="form-group"> |  | ||||||
|                 <label for="password">Username:</label> |  | ||||||
|                 <input type="password" name="password"> |  | ||||||
|                 <label for="password"><abbr title="required" aria-label="required">*</abbr></label> |  | ||||||
|             </div> |  | ||||||
|             <div class="form-group"> |  | ||||||
|                 <button type="submit">Login</button> |  | ||||||
|             </div> |  | ||||||
|         </fieldset> |  | ||||||
|     </form> |  | ||||||
| {% endblock content %} | {% endblock content %} | ||||||
|  | |||||||
							
								
								
									
										23
									
								
								templates/login_form.html.tera
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								templates/login_form.html.tera
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | |||||||
|  | {% extends "base" %} | ||||||
|  | 
 | ||||||
|  | {% block content %} | ||||||
|  |     <h1>Login</h1> | ||||||
|  |     <form action="/login" method="POST"> | ||||||
|  |         <fieldset> | ||||||
|  |             <legend>Login</legend> | ||||||
|  |             <div class="form-group"> | ||||||
|  |                 <label for="username">Username:</label> | ||||||
|  |                 <input type="text" name="username"> | ||||||
|  |                 <label for="username"><abbr title="required" aria-label="required">*</abbr></label> | ||||||
|  |             </div> | ||||||
|  |             <div class="form-group"> | ||||||
|  |                 <label for="password">Username:</label> | ||||||
|  |                 <input type="password" name="password"> | ||||||
|  |                 <label for="password"><abbr title="required" aria-label="required">*</abbr></label> | ||||||
|  |             </div> | ||||||
|  |             <div class="form-group"> | ||||||
|  |                 <button type="submit">Login</button> | ||||||
|  |             </div> | ||||||
|  |         </fieldset> | ||||||
|  |     </form> | ||||||
|  | {% endblock content %} | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Alex Wright
						Alex Wright