Rearrange functions

This commit is contained in:
max 2022-11-01 11:23:08 -05:00
parent 200942b2a2
commit 5a9ee796f8

View File

@ -13,6 +13,18 @@ type PostController struct {
App *app.App App *app.App
} }
func (postController *PostController) Login(w http.ResponseWriter, r *http.Request) {
username := r.FormValue("username")
password := r.FormValue("password")
if username == "" || password == "" {
log.Println("Tried to create user with empty username or password")
http.Redirect(w, r, "/register", http.StatusFound)
}
http.Redirect(w, r, "/login", http.StatusFound)
}
func (postController *PostController) Register(w http.ResponseWriter, r *http.Request) { func (postController *PostController) Register(w http.ResponseWriter, r *http.Request) {
username := r.FormValue("username") username := r.FormValue("username")
password := r.FormValue("password") password := r.FormValue("password")
@ -33,15 +45,3 @@ func (postController *PostController) Register(w http.ResponseWriter, r *http.Re
http.Redirect(w, r, "/login", http.StatusFound) http.Redirect(w, r, "/login", http.StatusFound)
} }
func (postController *PostController) Login(w http.ResponseWriter, r *http.Request) {
username := r.FormValue("username")
password := r.FormValue("password")
if username == "" || password == "" {
log.Println("Tried to create user with empty username or password")
http.Redirect(w, r, "/register", http.StatusFound)
}
http.Redirect(w, r, "/login", http.StatusFound)
}