Example #1
0
 def logout(self, workspace_id):
     log.debug("Logout.")
     init_session(c.workspace, reinit=True)
     redirect_to(
         url('invite_resend_show',
             workspace_id=workspace_id,
             info_code='logout'))
Example #2
0
 def logout(self, workspace_id, email_id):
     log.debug("Skurl logout.")
     init_session(c.workspace, reinit=True)
     ui_flash_info(code='logout', hide_after_ms=5000)
     redirect_to(
         url('teambox_pubws_show',
             workspace_id=workspace_id,
             email_id=email_id))
Example #3
0
    def show(self, workspace_id, email_id):
           
        ws = c.workspace
        
        if not ws: 
            log.warn("InvitationController().show(): Workspace %s does not exist." % ( workspace_id ) )
            abort(403)
        
        invitation = Invitation.get_by(email_id = email_id)
       
        if not invitation: 
            log.warn("InvitationController().show(): No invitation '%s' for workspace %s" \
                % ( email_id, workspace_id ) )
            ui_error(code="invitation_link_not_valid")
            return render('message/show.mako')
            #abort(403)

        if 'user_id' in session:
            if session['user_id'] == invitation.user_id:
                # User is already logged - redirect.
                redirect_to(url('teambox', workspace_id = session['workspace_id']))
            else:
                # User is logged as another user - unlog.
                init_session(c.workspace, reinit=True)
 
        if (ws.id==invitation.kws_id):
            ### Temp workaround to show notification management page for users with no passwords. ###
            session['tmp_notif_user_id'] = invitation.user_id
            session.save()
            c.notif_flag = True
            ### End workaround ###

            if ws.secured:
                c.email_id = email_id
                
                kcd_user = KcdUser.get_by(user_id = invitation.user_id, kws_id = invitation.kws_id)
                if not kcd_user:
                    log.warn("kcd user " + str(invitation.user_id) + " for workspace " + str(workspace_id) + " not found in database")
                    abort(403)

                if kcd_user.pwd: #prompt for password and for credentials download
                    c.show_pass = True
                    pass
                else: #prompt for credintials download
                    c.show_pass = False
                    pass
                return render('/invitation/show.mako')
            else: #authorize
                self._login(invitation)
        else:
            abort(403)
Example #4
0
 def logout(self, workspace_id):
     log.debug("Logout.")
     init_session(c.workspace, reinit=True)
     redirect_to(url('invite_resend_show', workspace_id=workspace_id, info_code='logout'))
Example #5
0
    def show(self, workspace_id, email_id):
        workspace_id = int(workspace_id)
        email_id = int(email_id)

        # Set logout url.
        c.logout_url = url('teambox_pubws_logout',
                           workspace_id=workspace_id,
                           email_id=email_id)

        # Check if the workspace is public.
        self._check_public(workspace_id)

        if 'email_id' in session and session['email_id'] != email_id:
            # User is logged but wants to access a different email. Reinit session.
            log.debug("Reinitializing session because user is using another email id: previous='%s', new='%s'." \
                % ( str(session['email_id']), str(email_id) ) )
            init_session(c.workspace, reinit=True)

        notif = request.GET.get('notif', 0)
        if notif:
            # This is the sender (user 1)... [re-]login automatically.
            log.debug(
                "User is accessing a public workspace using a notification link... automatically log user in."
            )
            user = User.get_by(workspace_id=workspace_id, id=1)
            log.debug(
                "Reinitializing session because user is logging as user 1 (notif management)."
            )
            init_session(c.workspace, reinit=True)
            self._login(user)
            c.notif_flag = True
        else:
            if 'user' in session and session['user'] and session['user'][
                    'id'] == 1:
                # Sender is logged (as a sender) but he's using a regular skurl link: logout.
                log.debug(
                    "Reinitializing session because user was logged as user 1 but is using a regular skurl link."
                )
                init_session(c.workspace, reinit=True)

        if not c.perms.hasRole('skurl'):
            # Give skurl role, if not already done.
            c.perms.addRole('skurl')

            # Save session.
            session.save()

        if not 'email_id' in session:
            # Set email information in session.

            # Instantiate a Kcd client.
            kc = KcdClient(get_cached_kcd_external_conf_object())

            # Check that email ID is valid.
            email_info = kc.pubws_get_email_info(workspace_id, email_id)
            if not email_info:
                log.debug("PubWS: invalild email ID: %i" % (email_id))
                abort(404)

            # Get the email sender.
            sender_user = User.get_by(workspace_id=workspace_id, id=1)
            sender = kbase.PropStore()
            sender.name = sender_user.real_name
            sender.email = sender_user.email

            # Get the email recipients (list of PropStores, having name and email keys).
            raw_recipients = kc.pubws_get_eid_recipient_identities(
                workspace_id, email_id)

            # Strip sender email from recipients, if needed.
            recipients = []
            for recipient in raw_recipients:
                if recipient.email != sender.email:
                    recipients.append(recipient)

            # Merge sender and recipients.
            identities = [sender] + recipients

            # Set needed informations in session.
            session['email_id'] = email_id
            session['email_info'] = email_info.to_dict()
            session['identities'] = map(lambda x: x.to_dict(), identities)
            session.save()

        # Get informations that will be published in the template.
        c.dyn_version = 15
        c.email_info = session['email_info']
        c.json_email_info_str = simplejson.dumps(c.email_info)
        c.identities = session['identities']
        c.json_identities_str = simplejson.dumps(c.identities)

        # Check if a chat request was accepted lately (delay is hardcoded in accepted_lately()).
        c.user_id = None
        if 'user_id' in session and session['user_id']:
            c.user_id = session['user_id']
            if ChatRequest.accepted_lately(workspace_id, session['user_id']):
                # Deny chat requests and allow chat since a request was accepted lately.
                self._set_chat_requests_perms(False)
                self._set_chat_perms(True)
            else:
                # Allow chat requests and deny chat since no request was accepted lately.
                self._set_chat_requests_perms(True)
                self._set_chat_perms(False)

            # Allow workspace creation request.
            self._set_ws_creation_requests_perms(True)

            # Save session.
            session.save()

        c.base_url_paths = kurl.get_base_url_paths(
            'teambox_updater', 'teambox_post_chat', 'teambox_download',
            'teambox_upload', 'teambox_pubws_set_identity',
            'teambox_pubws_chat_request', 'teambox_pubws_chat_request_result',
            'teambox_pubws_kfsup_request', 'teambox_pubws_kfsdown_request',
            'teambox_pubws_create_request')

        # Get first update directly.
        flags = (StateRequest.STATE_FORCE_SYNC
                 | StateRequest.STATE_WANT_PERMS
                 | StateRequest.STATE_WANT_MEMBERS
                 | StateRequest.STATE_WANT_KFS
                 | StateRequest.STATE_WANT_PUBWS_INFO)
        params = {}
        if 'user_id' in session and session['user_id']:
            flags |= StateRequest.STATE_WANT_CHAT
            params['chat_channel_id'] = session['user_id']
        updater_state_dict = state_request_get(c, session, flags, params)
        c.updater_state_json = simplejson.dumps(updater_state_dict)

        return render('/teambox/pubwsshow.mako')
Example #6
0
    def show(self, workspace_id, email_id):
        workspace_id = int(workspace_id)
        email_id = int(email_id)

        # Set logout url.
        c.logout_url = url('teambox_pubws_logout', workspace_id=workspace_id, email_id=email_id)

        # Check if the workspace is public.
        self._check_public(workspace_id)

        if 'email_id' in session and session['email_id'] != email_id:
            # User is logged but wants to access a different email. Reinit session.
            log.debug("Reinitializing session because user is using another email id: previous='%s', new='%s'." \
                % ( str(session['email_id']), str(email_id) ) )
            init_session(c.workspace, reinit=True)

        notif = request.GET.get('notif', 0)
        if notif:
            # This is the sender (user 1)... [re-]login automatically.
            log.debug("User is accessing a public workspace using a notification link... automatically log user in.")
            user = User.get_by(workspace_id=workspace_id, id=1)
            log.debug("Reinitializing session because user is logging as user 1 (notif management).")
            init_session(c.workspace, reinit=True)
            self._login(user)
            c.notif_flag = True
        else:
            if 'user' in session and session['user'] and session['user']['id'] == 1:
                # Sender is logged (as a sender) but he's using a regular skurl link: logout.
                log.debug("Reinitializing session because user was logged as user 1 but is using a regular skurl link.")
                init_session(c.workspace, reinit=True)

        if not c.perms.hasRole('skurl'):
            # Give skurl role, if not already done.
            c.perms.addRole('skurl')

            # Save session.
            session.save()

        if not 'email_id' in session:
            # Set email information in session.

            # Instantiate a Kcd client.
            kc = KcdClient(get_cached_kcd_external_conf_object())

            # Check that email ID is valid.
            email_info = kc.pubws_get_email_info(workspace_id, email_id)
            if not email_info:
                log.debug("PubWS: invalild email ID: %i" % ( email_id ) )
                abort(404)

            # Get the email sender.
            sender_user = User.get_by(workspace_id=workspace_id, id=1)
            sender = kbase.PropStore()
            sender.name = sender_user.real_name
            sender.email = sender_user.email

            # Get the email recipients (list of PropStores, having name and email keys).
            raw_recipients = kc.pubws_get_eid_recipient_identities(workspace_id, email_id)

            # Strip sender email from recipients, if needed.
            recipients = []
            for recipient in raw_recipients:
                if recipient.email != sender.email:
                    recipients.append(recipient)

            # Merge sender and recipients.
            identities = [sender] + recipients

            # Set needed informations in session.
            session['email_id'] = email_id
            session['email_info'] = email_info.to_dict()
            session['identities'] = map(lambda x: x.to_dict(), identities)
            session.save()

        # Get informations that will be published in the template. 
        c.dyn_version = 15
        c.email_info = session['email_info']
        c.json_email_info_str = simplejson.dumps(c.email_info)
        c.identities = session['identities']
        c.json_identities_str = simplejson.dumps(c.identities)

        # Check if a chat request was accepted lately (delay is hardcoded in accepted_lately()). 
        c.user_id = None
        if 'user_id' in session and session['user_id']:
            c.user_id = session['user_id']
            if ChatRequest.accepted_lately(workspace_id, session['user_id']):
                # Deny chat requests and allow chat since a request was accepted lately.
                self._set_chat_requests_perms(False)
                self._set_chat_perms(True)
            else:
                # Allow chat requests and deny chat since no request was accepted lately.
                self._set_chat_requests_perms(True)
                self._set_chat_perms(False)

            # Allow workspace creation request.
            self._set_ws_creation_requests_perms(True)

            # Save session.
            session.save()

        c.base_url_paths = kurl.get_base_url_paths(
            'teambox_updater',
            'teambox_post_chat',
            'teambox_download',
            'teambox_upload',
            'teambox_pubws_set_identity',
            'teambox_pubws_chat_request',
            'teambox_pubws_chat_request_result',
            'teambox_pubws_kfsup_request',
            'teambox_pubws_kfsdown_request',
            'teambox_pubws_create_request')

        # Get first update directly.
        flags = ( StateRequest.STATE_FORCE_SYNC 
                            | StateRequest.STATE_WANT_PERMS 
                            | StateRequest.STATE_WANT_MEMBERS
                            | StateRequest.STATE_WANT_KFS 
                            | StateRequest.STATE_WANT_PUBWS_INFO )
        params = { }
        if 'user_id' in session and session['user_id']:
            flags |= StateRequest.STATE_WANT_CHAT
            params['chat_channel_id'] = session['user_id']
        updater_state_dict = state_request_get(c, session, flags, params)
        c.updater_state_json = simplejson.dumps(updater_state_dict)

        return render('/teambox/pubwsshow.mako')
Example #7
0
 def logout(self, workspace_id, email_id):
     log.debug("Skurl logout.")
     init_session(c.workspace, reinit=True)
     ui_flash_info(code='logout', hide_after_ms=5000)
     redirect_to(url('teambox_pubws_show', workspace_id=workspace_id, email_id=email_id))