put new SAML users into correct categorycode
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 27 Jun 2011 09:37:12 +0000 (11:37 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 27 Jun 2011 09:38:31 +0000 (11:38 +0200)
C4/Auth.pm

index 20eb28c..c33b864 100644 (file)
@@ -188,12 +188,17 @@ sub get_template_and_user {
                                        $saml->{$n} = $v;
                                }
 
+                               my $categorycode =
+                                       $saml->{ATTR_code} =~ m/^\d{10}$/ ? 'S' : # JMBAG
+                                       $saml->{ATTR_code} =~ m/^\w\w\d+/ ? 'D' :
+                                       'O';
+
                                if ( $borrowernumber = getborrowernumber($saml->{ATTR_nick}) ) {
                                        warn "SAML login OK $borrowernumber";
                                } else {
                                        my $borrower = {
-                                               cardnumber => 'S' . $saml->{ATTR_code}, # FIXME
-                                               categorycode => 'S',
+                                               cardnumber => $categorycode . $saml->{ATTR_code},
+                                               categorycode => $categorycode,
 
                                                userid    => $saml->{ATTR_nick},
                                                firstname => $saml->{ATTR_first_name},