Example #1
0
 def index(self, came_from=lurl('/')):
     
     #print request.scheme   + '://';
     #hooks.notify('tgext.pylogservice.startup' ) 
     #hooks.notify('tgext.pyutilservice.startup')
     
     if not request.identity:
         ManageSession.deleteAll()
         
     if ManageSession.getLanguage() is None:
         ManageSession.setLanguage()
         
     print 'Session Language : %s' %(ManageSession.getLanguage())
     
     
     
     
     return dict(page='metronic') 
Example #2
0
    def post_login(self, came_from=lurl('/'), *args, **kw):

        log.info("post_login"); 
        
        if not request.identity:
            log.warning("user cannot login, redirect to login");
            login_counter = request.environ.get('repoze.who.logins', 0) + 1
            
            log.info( self.urlServer + '/login')
            redirect('/login', params=dict(came_from=came_from, __logins=login_counter))
            
        #userid = request.identity['repoze.who.userid'];
        user =  request.identity['user'];
        groups = request.identity['groups'] ;
        
        log.info("user in group : %s " %groups );
        
        userActive = model.UserGenCode.getUserActivated(user.user_id);
        
        if(userActive is None ):# and ('managers' not in groups  )):
            log.warning("user cannot login, redirect to login");
            flash(_('Please activate in your email'), 'warning') 
            #request.identity.current.logout();
            
            self.registerService.reActivateUser(user)
            
            auth_force_logout()
            login_counter = request.environ.get('repoze.who.logins', 0) ;
            
            redirect( '/login')#, params=dict(came_from=came_from, __logins=login_counter))
        
        print "add session"
        ManageSession.setLanguage('EN')
            
        #flash(_('Welcome back, %s!') % userid)
        
        if('/' == came_from):
            if ('voter' in groups):
                log.info("redirect to home page");
                #model.LogSurvey.insert(ip_server='127.0.0.1',status='INFO',message="redirect to home page" ,current_page='Login',user_name=user);
                log.info(self.urlServer + '/home' );
                redirect( '/home');
            if ('creator' in groups):
                log.info("redirect to create survey page");
                log.info(self.urlServer + '/survey' );
                #model.LogSurvey.insert(ip_server='127.0.0.1',status='INFO',message="redirect to create survey page" ,current_page='Login',user_name=user);
                redirect('/survey');
        
        
        
        #identity = request.environ.get('repoze.who.identity') 
        
        
        #for key in request.environ:
        #    print key 
        #    print request.environ[key];
        #    print '-------'
        #print "----------------------------------------------------------------";
        #for key in request.identity:
        #    print key 
        #    print request.identity[key];
        #    print '-------'
        #print "----------------------------------------------------------------";
        
        #print "User id "  ;
        #user =  request.identity['user'];
        #print user.user_id;
        
        """
        
        if 'voter' in groups:
            print "voter";
            log.info('voter');
            return HTTPFound(location='/survey')
        
        print "other";
        
        """
        
        
        
        # Do not use tg.redirect with tg.url as it will add the mountpoint
        # of the application twice.
        return HTTPFound(location=came_from)