LDAP support in views
authorLoic & Edelberto <loic.baron@lip6.fr>
Thu, 13 Mar 2014 13:23:20 +0000 (10:23 -0300)
committerLoic & Edelberto <loic.baron@lip6.fr>
Thu, 13 Mar 2014 13:23:20 +0000 (10:23 -0300)
portal/homeview.py
portal/registrationview.py
portal/theme.py

index 14487c9..bdaa6b9 100644 (file)
@@ -28,9 +28,16 @@ class HomeView (FreeAccessView, ThemeView):
         env['theme'] = self.theme
         username = request.POST.get('username')
         password = request.POST.get('password')
+       
+        # LDAP form - If FIBRE, then get the possibilite to authenticate using usernameldap
+        #if self.theme == 'fibre':
+        usernameldap = request.POST.get('usernameldap')
+        token = {'usernameldap': usernameldap, 'username': username ,'password': password, 'request': request}    
+        #else:
         
-        # pass request within the token, so manifold session key can be attached to the request session.
-        token = {'username': username, 'password': password, 'request': request}    
+        # Follow original code
+        ## pass request within the token, so manifold session key can be attached to the request session.
+        #token = {'username': username, 'password': password, 'request': request}    
 
         # our authenticate function returns either
         # . a ManifoldResult - when something has gone wrong, like e.g. backend is unreachable
index 9f5f39f..bfe49ff 100644 (file)
@@ -15,7 +15,9 @@ from manifoldapi.manifoldapi    import execute_admin_query
 from manifold.core.query        import Query
 
 from portal.models              import PendingUser
-from portal.actions             import create_pending_user
+#from portal.actions             import create_pending_user
+# Edelberto - LDAP
+from portal.actions             import create_pending_user, ldap_create_user
 
 from theme import ThemeView
 
@@ -122,8 +124,20 @@ class RegistrationView (FreeAccessView, ThemeView):
                 user_request['public_key']  = file_content
                 
             if not errors:
+                # verify if is a  LDAP 
+                mail = user_detail['email']
+                login = mail.split('@')[0]
+                org = mail.split('@')[1]
+                o = org.split('.')[-2]
+                dc = org.split('.')[-1]
+                # To know if user is a LDAP user - Need to has a 'dc' identifier
+                if dc == 'br' or 'eu':
+                    # LDAP insert directly - but with userEnable = FALSE
+                    ldap_create_user(wsgi_request, user_request, user_detail)
+               
                 create_pending_user(wsgi_request, user_request, user_detail)
                 self.template_name = 'user_register_complete.html'
+            
                 return render(wsgi_request, self.template, {'theme': self.theme}) 
 
         else:
index d44b854..0187ac1 100644 (file)
@@ -7,6 +7,7 @@ class ThemeView (object):
     @property
     def theme(self):
         self.config = ConfigEngine()
+        print self.config
         if self.config.myslice.theme :
             return self.config.myslice.theme
     
@@ -14,7 +15,7 @@ class ThemeView (object):
     def template(self):
         # Load a template from the theme directory if it exists
         # else load it from the common templates dir
-        print "THEME = ",self.theme
+        print "THEME 00 = ",self.theme
         print "TEMPLATE = ",self.template_name
         print "TEMPLATE_DIRS = ",TEMPLATE_DIRS
         filename = self.theme + '_' + self.template_name