From 51f25247aaae928d2bfb8f26d4b70e6e8cfa52d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz>
Date: Mon, 22 Mar 2021 21:42:08 +0100
Subject: [PATCH] Inteligentnejsi razeni uzivatelu

---
 .gitlab-ci.yml           | 2 +-
 lib/CF/Controller/SSO.pm | 9 ++++++++-
 openapi.yaml             | 6 +++---
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a6685c2..31a0396 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@ image: docker:19.03.12
 
 variables:
   DOCKER_TLS_CERTDIR: "/certs"
-  IMAGE_VER: 1.10.1
+  IMAGE_VER: 1.10.2
 
 services:
   - docker:19.03.12-dind
diff --git a/lib/CF/Controller/SSO.pm b/lib/CF/Controller/SSO.pm
index 7aae982..95e2af6 100644
--- a/lib/CF/Controller/SSO.pm
+++ b/lib/CF/Controller/SSO.pm
@@ -91,12 +91,19 @@ sub _users ($c, $search) {
             $user->{priority} = 1 if $user->{lastname}  =~ /^$search/i;
             $user->{priority} = 2 if $user->{username}  =~ /^$search/i;
             $user->{priority} = 3 if $user->{firstname} =~ /^$search/i;
+
+            $user->{priority} +=10 if scalar  @{ $user->{groups} };
+
+            GROUP:
+            foreach my $group ( @{ $user->{groups}} ) {
+                $user->{priority} +=100 if $group =~ /^cen:(f|regp)/; #TODO: do cfg
+            }
+
             push @tmp, $user,
         }
 
         USER:
         foreach my $user ( sort {
-            $b->{included}      <=> $a->{included} or
             $b->{priority}      <=> $a->{priority} or
             lc($a->{firstname}) cmp lc($b->{firstname}) or
             lc($a->{lastname})  cmp lc($b->{lastname})
diff --git a/openapi.yaml b/openapi.yaml
index 625cfcb..dfc73fd 100644
--- a/openapi.yaml
+++ b/openapi.yaml
@@ -1,7 +1,7 @@
 openapi: 3.0.3
 
 info:
-  version: 1.8.0
+  version: 1.10.2
   title: CF Online
   description: CF Online
   license:
@@ -13,10 +13,10 @@ info:
     url: https://pardubicky.pirati.cz/lide/andrej-ramaseuski/
 
 servers:
-    - url: http://127.0.0.1:3000/api
-      description: Developement server
     - url: https://cf2021.pirati.cz/api
       description: Production server
+    - url: http://127.0.0.1:3000/api
+      description: Developement server
 
 components:
   securitySchemes:
-- 
GitLab