small changes

This commit is contained in:
Arnaud Delcasse 2025-02-26 14:39:56 +01:00
parent 7c78ce9c37
commit a75a31b151
5 changed files with 142 additions and 1568 deletions

View File

@ -19,7 +19,7 @@ COPY . .
RUN go mod download && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server RUN go mod download && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server
RUN rm -r themes/* #RUN rm -r themes/*
RUN git clone --depth 1 https://git.coopgo.io/coopgo-apps/parcoursmob-default-theme themes/default RUN git clone --depth 1 https://git.coopgo.io/coopgo-apps/parcoursmob-default-theme themes/default
RUN git clone -b spie06 --depth 1 https://git.coopgo.io/coopgo-apps/parcoursmob-default-theme themes/spie06 RUN git clone -b spie06 --depth 1 https://git.coopgo.io/coopgo-apps/parcoursmob-default-theme themes/spie06

86
go.mod
View File

@ -1,6 +1,8 @@
module git.coopgo.io/coopgo-apps/parcoursmob module git.coopgo.io/coopgo-apps/parcoursmob
go 1.18 go 1.22.0
toolchain go1.23.3
// replace git.coopgo.io/coopgo-platform/mobility-accounts => ../../coopgo-platform/mobility-accounts/ // replace git.coopgo.io/coopgo-platform/mobility-accounts => ../../coopgo-platform/mobility-accounts/
@ -16,55 +18,47 @@ require (
github.com/coreos/go-oidc v2.2.1+incompatible github.com/coreos/go-oidc v2.2.1+incompatible
github.com/fogleman/gg v1.3.0 github.com/fogleman/gg v1.3.0
github.com/go-playground/validator/v10 v10.11.0 github.com/go-playground/validator/v10 v10.11.0
github.com/google/uuid v1.3.0 github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.0 github.com/gorilla/mux v1.8.0
github.com/gorilla/sessions v1.2.1 github.com/gorilla/sessions v1.2.1
github.com/paulmach/go.geojson v1.4.0 github.com/paulmach/go.geojson v1.4.0
github.com/spf13/viper v1.13.0 github.com/spf13/viper v1.19.0
gitlab.scity.coop/maas/navitia-golang v0.0.0-20220429110621-5c22d6efdd0c gitlab.scity.coop/maas/navitia-golang v0.0.0-20220429110621-5c22d6efdd0c
go.etcd.io/etcd/client/v3 v3.5.4 go.etcd.io/etcd/client/v3 v3.5.12
golang.org/x/image v0.5.0 golang.org/x/image v0.5.0
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 golang.org/x/oauth2 v0.25.0
google.golang.org/grpc v1.48.0 google.golang.org/grpc v1.67.3
google.golang.org/protobuf v1.28.1 google.golang.org/protobuf v1.36.1
) )
require ( require (
git.coopgo.io/coopgo-platform/agenda v0.0.0-20230310121901-ef3add576f86 git.coopgo.io/coopgo-platform/agenda v0.0.0-20230310121901-ef3add576f86
git.coopgo.io/coopgo-platform/emailing v0.0.0-20221017030337-c71888d90c15 git.coopgo.io/coopgo-platform/emailing v0.0.0-20250212064257-167ef5864260
git.coopgo.io/coopgo-platform/fleets v0.0.0-20230310144446-feb935f8bf4e git.coopgo.io/coopgo-platform/fleets v0.0.0-20230310144446-feb935f8bf4e
git.coopgo.io/coopgo-platform/groups-management v0.0.0-20230310123255-5ef94ee0746c git.coopgo.io/coopgo-platform/groups-management v0.0.0-20230310123255-5ef94ee0746c
git.coopgo.io/coopgo-platform/mobility-accounts v0.0.0-20230430115320-f5bb2e7c2c26 git.coopgo.io/coopgo-platform/mobility-accounts v0.0.0-20230430115320-f5bb2e7c2c26
github.com/gorilla/securecookie v1.1.1 github.com/gorilla/securecookie v1.1.1
github.com/minio/minio-go/v7 v7.0.43 github.com/minio/minio-go/v7 v7.0.43
github.com/ory/viper v1.7.5
github.com/xuri/excelize/v2 v2.7.1 github.com/xuri/excelize/v2 v2.7.1
) )
require ( require (
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/dgraph-io/ristretto v0.0.3 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect github.com/dustin/go-humanize v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/golang/protobuf v1.5.2 // indirect github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.1 // indirect github.com/golang/snappy v0.0.1 // indirect
github.com/gorilla/csrf v1.7.1 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.9 // indirect github.com/klauspost/compress v1.17.2 // indirect
github.com/klauspost/cpuid/v2 v2.1.0 // indirect github.com/klauspost/cpuid/v2 v2.1.0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect github.com/leodido/go-urn v1.2.1 // indirect
github.com/magiconair/properties v1.8.6 // indirect github.com/magiconair/properties v1.8.9 // indirect
github.com/mattn/goveralls v0.0.6 // indirect
github.com/mb0/wkt v0.0.0-20170420051526-a30afd545ee1 // indirect github.com/mb0/wkt v0.0.0-20170420051526-a30afd545ee1 // indirect
github.com/minio/md5-simd v1.1.2 // indirect github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect github.com/minio/sha256-simd v1.0.0 // indirect
@ -73,53 +67,45 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/ory/fosite v0.42.2 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/ory/go-acc v0.2.6 // indirect
github.com/ory/go-convenience v0.1.0 // indirect
github.com/ory/x v0.0.214 // indirect
github.com/pborman/uuid v1.2.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/pquerna/cachecontrol v0.1.0 // indirect github.com/pquerna/cachecontrol v0.1.0 // indirect
github.com/richardlehane/mscfb v1.0.4 // indirect github.com/richardlehane/mscfb v1.0.4 // indirect
github.com/richardlehane/msoleps v1.0.3 // indirect github.com/richardlehane/msoleps v1.0.3 // indirect
github.com/rs/xid v1.4.0 // indirect github.com/rs/xid v1.4.0 // indirect
github.com/sagikazarmark/locafero v0.7.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/afero v1.8.2 // indirect github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/cast v1.5.0 // indirect github.com/spf13/afero v1.12.0 // indirect
github.com/spf13/cobra v1.0.0 // indirect github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.6 // indirect
github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/tidwall/pretty v1.1.0 // indirect github.com/tidwall/pretty v1.1.0 // indirect
github.com/twpayne/go-geom v1.3.6 // indirect github.com/twpayne/go-geom v1.2.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.etcd.io/etcd/api/v3 v3.5.4 // indirect go.etcd.io/etcd/api/v3 v3.5.12 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.4 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.12 // indirect
go.mongodb.org/mongo-driver v1.10.1 // indirect go.mongodb.org/mongo-driver v1.10.1 // indirect
go.uber.org/atomic v1.7.0 // indirect go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.6.0 // indirect go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.17.0 // indirect go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.8.0 // indirect golang.org/x/crypto v0.33.0 // indirect
golang.org/x/net v0.9.0 // indirect golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3 // indirect
golang.org/x/sync v0.1.0 // indirect golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.7.0 // indirect golang.org/x/sync v0.11.0 // indirect
golang.org/x/text v0.9.0 // indirect golang.org/x/sys v0.30.0 // indirect
golang.org/x/tools v0.6.0 // indirect golang.org/x/text v0.22.0 // indirect
google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/mail.v2 v2.3.1 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
gopkg.in/square/go-jose.v2 v2.5.2-0.20210529014059-a5c7eec3c614 // indirect gopkg.in/square/go-jose.v2 v2.5.2-0.20210529014059-a5c7eec3c614 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )

1592
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -242,7 +242,8 @@ func (h *ApplicationHandler) AdministrationGroupInviteAdmin(w http.ResponseWrite
fmt.Println(err) fmt.Println(err)
data := map[string]any{ data := map[string]any{
"group": groupresp.Group.ToStorageType().Data["name"], "group": groupresp.Group.ToStorageType().Data["name"],
"baseUrl": h.config.GetString("base_url"),
} }
if err := h.emailing.Send("onboarding.existing_administrator", r.FormValue("username"), data); err != nil { if err := h.emailing.Send("onboarding.existing_administrator", r.FormValue("username"), data); err != nil {
@ -267,11 +268,16 @@ func (h *ApplicationHandler) AdministrationGroupInviteAdmin(w http.ResponseWrite
} }
key := base64.RawURLEncoding.EncodeToString(b) key := base64.RawURLEncoding.EncodeToString(b)
h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour) // 1 week TTL if err := h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour); err != nil { // 1 week TTL
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
data := map[string]any{ data := map[string]any{
"group": groupresp.Group.ToStorageType().Data["name"], "group": groupresp.Group.ToStorageType().Data["name"],
"key": key, "key": key,
"baseUrl": h.config.GetString("base_url"),
} }
if err := h.emailing.Send("onboarding.new_administrator", r.FormValue("username"), data); err != nil { if err := h.emailing.Send("onboarding.new_administrator", r.FormValue("username"), data); err != nil {
@ -282,7 +288,6 @@ func (h *ApplicationHandler) AdministrationGroupInviteAdmin(w http.ResponseWrite
} }
http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound) http.Redirect(w, r, fmt.Sprintf("/app/administration/groups/%s", groupid), http.StatusFound)
return
} }
func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWriter, r *http.Request) { func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWriter, r *http.Request) {
@ -325,7 +330,8 @@ func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWrit
fmt.Println(err) fmt.Println(err)
data := map[string]any{ data := map[string]any{
"group": group.Data["name"], "group": group.Data["name"],
"baseUrl": h.config.GetString("base_url"),
} }
if err := h.emailing.Send("onboarding.existing_member", r.FormValue("username"), data); err != nil { if err := h.emailing.Send("onboarding.existing_member", r.FormValue("username"), data); err != nil {
@ -353,8 +359,9 @@ func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWrit
h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour) // 1 week TTL h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour) // 1 week TTL
data := map[string]any{ data := map[string]any{
"group": group.Data["name"], "group": group.Data["name"],
"key": key, "key": key,
"baseUrl": h.config.GetString("base_url"),
} }
if err := h.emailing.Send("onboarding.new_member", r.FormValue("username"), data); err != nil { if err := h.emailing.Send("onboarding.new_member", r.FormValue("username"), data); err != nil {

View File

@ -137,14 +137,14 @@ func main() {
/********************Code Supprt Emailing************************/ /********************Code Supprt Emailing************************/
application.HandleFunc("/support/", applicationHandler.SupportSend) application.HandleFunc("/support/", applicationHandler.SupportSend)
/*********************** CODE GROUP **************************/
/*********************** CODE GROUP **************************/
appGroup := application.PathPrefix("/group_module").Subrouter() appGroup := application.PathPrefix("/group_module").Subrouter()
appGroup.HandleFunc("/", applicationHandler.Groups) appGroup.HandleFunc("/", applicationHandler.Groups)
appGroup.HandleFunc("/groups", applicationHandler.CreateGroupModule) appGroup.HandleFunc("/groups", applicationHandler.CreateGroupModule)
appGroup.HandleFunc("/groups/{groupid}", applicationHandler.DisplayGroupModule) appGroup.HandleFunc("/groups/{groupid}", applicationHandler.DisplayGroupModule)
//TODO Subrouters with middlewares checking security for each module ? // TODO Subrouters with middlewares checking security for each module ?
application.Use(idp.Middleware) application.Use(idp.Middleware)
application.Use(idp.GroupsMiddleware) application.Use(idp.GroupsMiddleware)
@ -154,7 +154,7 @@ func main() {
appAdmin.HandleFunc("/groups/{groupid}", applicationHandler.AdministrationGroupDisplay) appAdmin.HandleFunc("/groups/{groupid}", applicationHandler.AdministrationGroupDisplay)
appAdmin.HandleFunc("/groups/{groupid}/invite-admin", applicationHandler.AdministrationGroupInviteAdmin) appAdmin.HandleFunc("/groups/{groupid}/invite-admin", applicationHandler.AdministrationGroupInviteAdmin)
appAdmin.HandleFunc("/groups/{groupid}/invite-member", applicationHandler.AdministrationGroupInviteMember) appAdmin.HandleFunc("/groups/{groupid}/invite-member", applicationHandler.AdministrationGroupInviteMember)
//add statistiques // add statistiques
appAdmin.HandleFunc("/stats/vehicles", applicationHandler.AdminStatVehicles) appAdmin.HandleFunc("/stats/vehicles", applicationHandler.AdminStatVehicles)
appAdmin.HandleFunc("/stats/bookings", applicationHandler.AdminStatBookings) appAdmin.HandleFunc("/stats/bookings", applicationHandler.AdminStatBookings)
appAdmin.HandleFunc("/stats/beneficaires", applicationHandler.AdminStatBeneficaires) appAdmin.HandleFunc("/stats/beneficaires", applicationHandler.AdminStatBeneficaires)
@ -183,7 +183,6 @@ func main() {
} }
log.Fatal(srv.ListenAndServe()) log.Fatal(srv.ListenAndServe())
} }
func redirectApp(w http.ResponseWriter, r *http.Request) { func redirectApp(w http.ResponseWriter, r *http.Request) {