Skip to content

Commit

Permalink
login start
Browse files Browse the repository at this point in the history
  • Loading branch information
Pomog committed Dec 24, 2023
1 parent b76353b commit 088e79e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
1 change: 1 addition & 0 deletions cmd/web/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func routes(app *config.AppConfig) http.Handler {
mux.Get("/reservation-summary", handlers.Repo.ReservationSummary)

mux.Get("/user-login", handlers.Repo.ShowLogin)
mux.Post("/user-login", handlers.Repo.PostShowLogin)

fileServer := http.FileServer(http.Dir("./static/"))
mux.Handle("/static/*", http.StripPrefix("/static", fileServer))
Expand Down
4 changes: 4 additions & 0 deletions internal/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,3 +453,7 @@ func (m *Repository) ShowLogin(w http.ResponseWriter, r *http.Request) {
Form: forms.New(nil),
})
}

func (m *Repository) PostShowLogin(w http.ResponseWriter, r *http.Request) {
log.Println("PostShowLogin - works")
}
Binary file removed internal/repository/dbrepo/mainDB copy.db
Binary file not shown.
Binary file removed internal/repository/dbrepo/mainDB.db
Binary file not shown.
45 changes: 25 additions & 20 deletions templates/login.page.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,31 @@
<div class="row">
<div class="col">
<h1>Login</h1>
<div class="form-group mt-3">
<label for="emial">Email</label>
{{with.Form.Errors.Get "email"}}
<label class="text-danger">{{.}}</label>
{{end}}
<input class='form-control {{ with.Form.Errors.Get "email"}} is-invalid {{end}}'
id="email" autocomplete="off" type='email'
name='email' value="" required>
</div>
<div class="form-group">
<label for="password">Password</label>
{{with.Form.Errors.Get "password"}}
<label class="text-danger">{{.}}</label>
{{end}}
<input class='form-control {{ with.Form.Errors.Get "password"}} is-invalid {{end}}'
id="password" autocomplete="off" type='password'
name='password' value="" required>
</div>
<hr>
<input type="submit" class="button-primary" value="submit">

<form method="post" action="/user-login">
<input type="hidden" name="csrf_token" value="{{.CSRFToken}}">

<div class="form-group mt-3">
<label for="emial">Email</label>
{{with.Form.Errors.Get "email"}}
<label class="text-danger">{{.}}</label>
{{end}}
<input class='form-control {{ with.Form.Errors.Get "email"}} is-invalid {{end}}'
id="email" autocomplete="off" type='email'
name='email' value="" required>
</div>
<div class="form-group">
<label for="password">Password</label>
{{with.Form.Errors.Get "password"}}
<label class="text-danger">{{.}}</label>
{{end}}
<input class='form-control {{ with.Form.Errors.Get "password"}} is-invalid {{end}}'
id="password" autocomplete="off" type='password'
name='password' value="" required>
</div>
<hr>
<input type="submit" class="button-primary" value="submit">
</form>
</div>
</div>
</div>
Expand Down

0 comments on commit 088e79e

Please sign in to comment.