-
Notifications
You must be signed in to change notification settings - Fork 0
/
portal.go
77 lines (73 loc) · 1.9 KB
/
portal.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package router
import (
"fmt"
"html/template"
"net/http"
"github.com/n-creativesystem/go-fwncs"
"github.com/n-creativesystem/go-fwncs/sessions"
"github.com/oidc-proxy-ecosystem/proxy-server/config"
)
func oidcPortal(c fwncs.Context) {
mp, err, redirect := getUserInfo(c)
if redirect {
c.Redirect(http.StatusTemporaryRedirect, "/auth/login")
return
}
if err != nil {
c.Logger().Error(err)
c.AbortWithStatusAndErrorMessage(http.StatusInternalServerError, err)
return
}
picture, ok := mp["picture"].(string)
if !ok {
picture = "/images/user.png"
}
t := template.Must(template.ParseFiles("public/templates/layout.html", "public/templates/index.html"))
if err = t.Execute(c.Writer(), struct {
Title string
Url string
Picture string
Menus []*config.Menu
}{
Title: "Portal",
Picture: picture,
Menus: config.Menus,
}); err != nil {
c.AbortWithStatusAndErrorMessage(http.StatusInternalServerError, err)
}
}
func samlPortal(c fwncs.Context) {
session := sessions.Default(c)
// mp, err, redirect := getUserInfo(c)
// if redirect {
// c.Redirect(http.StatusTemporaryRedirect, "/auth/login")
// return
// }
// if err != nil {
// c.Logger().Error(err)
// c.AbortWithStatusAndErrorMessage(http.StatusInternalServerError, err)
// return
// }
var picture string = "/images/user.png"
// picture, ok := mp["picture"].(string)
// if !ok {
// picture = "/images/user.png"
// }
value := session.Get("saml_user")
c.Logger().Info(fmt.Sprintf("%#v", value))
t := template.Must(template.ParseFiles("public/templates/layout.html", "public/templates/index.html"))
if err := t.Execute(c.Writer(), struct {
Title string
Url string
Picture string
Menus []*config.Menu
Value interface{}
}{
Title: "Portal",
Picture: picture,
Menus: config.Menus,
Value: value,
}); err != nil {
c.AbortWithStatusAndErrorMessage(http.StatusInternalServerError, err)
}
}