diff --git a/cmd/mi/middleware.go b/cmd/mi/middleware.go index 130fd1e..d3896b1 100644 --- a/cmd/mi/middleware.go +++ b/cmd/mi/middleware.go @@ -5,6 +5,7 @@ import ( "encoding/hex" "flag" "net/http" + "strings" "time" "github.com/google/uuid" @@ -80,8 +81,6 @@ var publicRoutes map[string]bool func init() { publicRoutes = map[string]bool{ - "/webhooks/": true, - "/static/": true, "/static/main.js": true, "/static/gruvbox.css": true, "/static/favicon.ico": true, @@ -89,7 +88,6 @@ func init() { "/debug/requests": true, "/debug/events": true, "/sign-in": true, - "/switch": true, } } @@ -105,19 +103,27 @@ func (pm PasetoMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request) { var newFooter string var err error - if r.URL.EscapedPath() == "/.within/botinfo" || r.URL.EscapedPath() == "/" { + if r.URL.Path == "/.within/botinfo" || r.URL.Path == "/" { + goto ok + } + + if strings.HasPrefix(r.URL.Path, "/webhooks/") { + goto ok + } + + if strings.HasPrefix(r.URL.Path, "/static/img") { goto ok } for k := range publicRoutes { - if r.URL.EscapedPath() == k { + if r.URL.Path == k { goto ok } } err = pm.v2.Verify(tok, pm.pubKey, &newJsonToken, &newFooter) if err != nil { - http.Error(w, "Not allowed", http.StatusForbidden) + http.Redirect(w, r, "/sign-in", http.StatusTemporaryRedirect) return } diff --git a/frontend/src/Pages/Switch.elm b/frontend/src/Pages/Switch.elm index fe6936e..1337657 100644 --- a/frontend/src/Pages/Switch.elm +++ b/frontend/src/Pages/Switch.elm @@ -5,6 +5,8 @@ import Element.Font as Font import Element.Input as Input import Generated.Params as Params import Global +import Html +import Html.Attributes import Http import Iso8601 import Json.Decode @@ -170,7 +172,17 @@ view model = in column [] - [ el [ Font.size 30 ] (text data.who) + [ row [] + [ html + (Html.img + [ Html.Attributes.src ("/static/img/" ++ String.toLower data.who ++ ".png") + , Html.Attributes.width 64 + , Html.Attributes.height 64 + ] + [] + ) + , el [ Font.size 30 ] (text data.who) + ] , text ("started at " ++ startTime) ] @@ -188,7 +200,7 @@ view model = Input.button [] { onPress = Just NextPage, label = text "Next" } tableButtons = - row [] [ prevButton, nextButton ] + row [] [ prevButton, text "-", nextButton ] switchDataTable = case model.frontData of @@ -215,7 +227,7 @@ view model = , mouseOver [ alpha 0.5 ] ] { label = text (String.slice 0 10 switch.id) - , url = "/switch/" ++ switch.id + , url = "/switch/id/" ++ switch.id } } , { header = text "Who" diff --git a/static/img/ashe.png b/static/img/ashe.png new file mode 100644 index 0000000..a622f09 Binary files /dev/null and b/static/img/ashe.png differ diff --git a/static/img/cadey.png b/static/img/cadey.png new file mode 100644 index 0000000..f62ea11 Binary files /dev/null and b/static/img/cadey.png differ diff --git a/static/img/jessie.png b/static/img/jessie.png new file mode 100644 index 0000000..baf3b65 Binary files /dev/null and b/static/img/jessie.png differ diff --git a/static/img/mai.png b/static/img/mai.png new file mode 100644 index 0000000..a530fc1 Binary files /dev/null and b/static/img/mai.png differ diff --git a/static/img/nicole.png b/static/img/nicole.png new file mode 100644 index 0000000..9ddb03f Binary files /dev/null and b/static/img/nicole.png differ diff --git a/static/img/sephie.png b/static/img/sephie.png new file mode 100644 index 0000000..74790d0 Binary files /dev/null and b/static/img/sephie.png differ