Add sign in handler
This commit is contained in:
@@ -45,6 +45,21 @@ func (u Users) GetSignin(w http.ResponseWriter, r *http.Request) {
|
||||
data.Email = r.FormValue("email")
|
||||
u.Templates.Signin.Execute(w, data)
|
||||
}
|
||||
func (u Users) PostSignin(w http.ResponseWriter, r *http.Request) {
|
||||
var data struct {
|
||||
Email string
|
||||
Password string
|
||||
}
|
||||
data.Email = r.FormValue("email")
|
||||
data.Password = r.FormValue("password")
|
||||
user, err := u.UserService.Authenticate(data.Email, data.Password)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
http.Error(w, "Something went wrong.", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(w, "User authenticated: %+v", user)
|
||||
}
|
||||
|
||||
func WithTemplates(user_service *models.UserService, signup Template, signin Template) Users {
|
||||
u := Users{}
|
||||
|
||||
Reference in New Issue
Block a user