diff --git a/.gitignore b/.gitignore index 5c0581f..001eed0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ foods.db -server.conf \ No newline at end of file +server.conf +server \ No newline at end of file diff --git a/README.md b/README.md index f85c9d1..92b8d55 100644 --- a/README.md +++ b/README.md @@ -4,5 +4,4 @@ FOODOLES Projet Go de vote pour choisir ce qu'on mange au déjeuner TODO : - Afficher une liste de restaurants locaux répondant au vote du jour - Afficher le résultat du vote \ No newline at end of file + Afficher une liste de restaurants locaux répondant au vote du jour \ No newline at end of file diff --git a/auth/auth.go b/auth/auth.go index de17ff9..50d4795 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -11,7 +11,7 @@ import ( // LogIn auth the client func LogIn(username string, password string) (ok bool, user map[string]string) { - var configFile = "../server.conf" + var configFile = "server.conf" var conf *config.Config var conferr error conf, conferr = config.NewFromFile(configFile) @@ -30,6 +30,7 @@ func LogIn(username string, password string) (ok bool, user map[string]string) { GroupFilter: "(memberUid=%s)", Attributes: conf.LDAP.Attributes, } + log.Print(ldapclient) defer ldapclient.Close() ok, user, err := ldapclient.Authenticate(username, password) diff --git a/foods.db b/foods.db index e06ad13..fb78bed 100644 Binary files a/foods.db and b/foods.db differ diff --git a/server b/server index 9a1dcbd..ab1acab 100755 Binary files a/server and b/server differ diff --git a/server.go b/server.go index 6fc688c..6a76d9d 100644 --- a/server.go +++ b/server.go @@ -1,6 +1,7 @@ package main import ( + "cadoles/foodoles/auth" "cadoles/foodoles/bdd" "cadoles/foodoles/config" "cadoles/foodoles/foodlist" @@ -51,12 +52,14 @@ func main() { // ServerHTTP is the entry point to all requests func (u *User) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if err := r.ParseForm(); err != nil { log.Printf("ParseForm() err: %v", err) } else { u.Auth(r.FormValue("user"), r.FormValue("password")) } if u.Name == "" { + LogInPage(w, r) return } @@ -77,14 +80,14 @@ func (u *User) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Auth is the login page for user func (u *User) Auth(user string, pass string) bool { - // auth, _ := auth.LogIn(user, pass) - // if auth { - // u.Name = user - // u.Password = pass - // } - u.Name = "mlamalle" - u.Password = "password" - var auth = true + auth, _ := auth.LogIn(user, pass) + if auth { + u.Name = user + u.Password = pass + } + // auth := true + // u.Name = "mlamalle" + // u.Password = "pass" return auth }