From 123135dd9db5439a5307173e0c44c2d283926370 Mon Sep 17 00:00:00 2001 From: fiftin Date: Mon, 11 Mar 2024 15:17:53 +0100 Subject: [PATCH] feat(be): sort oauth providers --- api/login.go | 9 +++++++++ util/config.go | 1 + web/src/App.vue | 3 +++ web/src/views/Auth.vue | 12 +++++++++++- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/api/login.go b/api/login.go index 9a37d972..f51b73a9 100644 --- a/api/login.go +++ b/api/login.go @@ -10,6 +10,7 @@ import ( "net/http" "net/url" "os" + "sort" "strconv" "strings" "time" @@ -212,6 +213,7 @@ func login(w http.ResponseWriter, r *http.Request) { LoginWithPassword: !util.Config.PasswordLoginDisable, } i := 0 + for k, v := range util.Config.OidcProviders { config.OidcProviders[i] = loginMetadataOidcProvider{ ID: k, @@ -221,6 +223,13 @@ func login(w http.ResponseWriter, r *http.Request) { } i++ } + + sort.Slice(config.OidcProviders, func(i, j int) bool { + a := util.Config.OidcProviders[config.OidcProviders[i].ID] + b := util.Config.OidcProviders[config.OidcProviders[j].ID] + return a.Order < b.Order + }) + helpers.WriteJSON(w, http.StatusOK, config) return } diff --git a/util/config.go b/util/config.go index 40b6fb9c..4d5d7adf 100644 --- a/util/config.go +++ b/util/config.go @@ -75,6 +75,7 @@ type OidcProvider struct { NameClaim string `json:"name_claim" default:"preferred_username"` EmailClaim string `json:"email_claim" default:"email"` EmailSuffix string `json:"email_suffix"` + Order int `json:"order"` } const ( diff --git a/web/src/App.vue b/web/src/App.vue index a92ce8df..7fc4b53d 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -773,6 +773,9 @@ export default { }, project() { + if (this.projects == null) { + return null; + } return this.projects.find((x) => x.id === this.projectId); }, diff --git a/web/src/views/Auth.vue b/web/src/views/Auth.vue index e5c5b0cf..eda5bf7e 100644 --- a/web/src/views/Auth.vue +++ b/web/src/views/Auth.vue @@ -77,8 +77,18 @@ ref="signInForm" lazy-validation v-model="signInFormValid" - style="width: 300px; height: 300px;" + style="width: 300px;" > + + +

{{ $t('semaphore') }}