/
consent.go
42 lines (35 loc) · 854 Bytes
/
consent.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package handlers
import (
"net/http"
"net/url"
log "github.com/cihub/seelog"
"github.com/gin-gonic/gin"
"github.com/go-session/session"
)
func Consent(ctx *gin.Context) {
w := ctx.Writer
r := ctx.Request
store, err := session.Start(ctx.Request.Context(), w, r)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if _, ok := store.Get("LoggedInUserID"); !ok {
w.Header().Set("Location", "/login")
w.WriteHeader(http.StatusFound)
return
}
var form url.Values
if v, ok := store.Get("ReturnUri"); ok {
// mapVal := v.(map[string]interface{})
// for m, val := range mapVal {
// form[m] = val.(string)
// }
form = v.(url.Values)
}
if v, ok := store.Get("state"); ok {
//r.Form.Set("state", v.(string))
log.Infof("State:%s", v)
}
ctx.HTML(http.StatusOK, "consent.html", form)
}