Compare commits
No commits in common. "7bf6ffd4176844e472acc2ec66df9acf1315ac07" and "62a91653c35615b71bdd34b67372511035467237" have entirely different histories.
7bf6ffd417
...
62a91653c3
|
@ -1,3 +1,2 @@
|
|||
foods.db
|
||||
server.conf
|
||||
server
|
||||
server.conf
|
|
@ -4,4 +4,5 @@ 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 une liste de restaurants locaux répondant au vote du jour
|
||||
Afficher le résultat du vote
|
|
@ -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,7 +30,6 @@ 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)
|
||||
|
|
19
server.go
19
server.go
|
@ -1,7 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"cadoles/foodoles/auth"
|
||||
"cadoles/foodoles/bdd"
|
||||
"cadoles/foodoles/config"
|
||||
"cadoles/foodoles/foodlist"
|
||||
|
@ -52,14 +51,12 @@ 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
|
||||
}
|
||||
|
@ -80,14 +77,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
|
||||
}
|
||||
// auth := true
|
||||
// u.Name = "mlamalle"
|
||||
// u.Password = "pass"
|
||||
// auth, _ := auth.LogIn(user, pass)
|
||||
// if auth {
|
||||
// u.Name = user
|
||||
// u.Password = pass
|
||||
// }
|
||||
u.Name = "mlamalle"
|
||||
u.Password = "password"
|
||||
var auth = true
|
||||
return auth
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<title>Foodoles written in Go</title>
|
||||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.css">
|
||||
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.js"></script>
|
||||
<style type="text/css">body { font-family: arial } h2 { margin: 2em 0em; } .ui.container { padding-top: 5em; padding-bottom: 5em; } </style>
|
||||
<style type="text/css"> h2 { margin: 2em 0em; } .ui.container { padding-top: 5em; padding-bottom: 5em; } </style>
|
||||
<script type="text/javascript">
|
||||
function vote(option){$.post( "/", {option}, ( data ) => { $('.modal').modal('show');});}
|
||||
function reload(){document.location.reload(true);}
|
||||
|
@ -16,9 +16,9 @@
|
|||
<div class="ui container">
|
||||
<h1 class="ui header">Foodoles - {{.Foods.Date}}</h1><br/>
|
||||
<h2 class="ui header">Pick Your Preferred Lunch's Food For Today</h2><br/>
|
||||
<div class="ui ">
|
||||
<div class="ui compact menu">
|
||||
{{ range .Foods.Foods }}
|
||||
<a onclick="vote('{{ .Title }}')" class="ui label massive" data-tooltip="{{ .Title }}" data-variation="basic" data-position="bottom left">
|
||||
<a onclick="vote('{{ .Title }}')" class="ui item label massive">
|
||||
{{$cur := .Title}}
|
||||
{{ .Icon }}
|
||||
{{ range $.Votes.Votes }}
|
||||
|
|
Loading…
Reference in New Issue