Exemplo n.º 1
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)
Exemplo n.º 2
0
    def get(self, workspace_id, email_id):
        # Return a rendered template
        #return render('/credentials_file.mako')
        # or, return a response
        response.content_type = "application/wsl"

        filename = "kwmo_creds.wsl"
        # Temporarily disabled - need to be debugged.
        if request.params.has_key('interactive') and str(request.params.get('interactive')) == "1":
            filename = c.workspace.name + ".wsl"

        response.headers['Content-disposition'] = 'attachment; filename="%s"' % ( filename.encode('latin1') )
        
        #fix for IE
        response.headers['Pragma'] = 'public'
        response.headers['Cache-Control'] = 'max-age-0'

        errorStr = None
        #ws = Workspace.get_by(id= workspace_id)
        ws = c.workspace
        invitation = Invitation.get_by(email_id = email_id)
        
        if (ws and invitation):
            user = User.get_by(id = invitation.user_id, workspace=ws)
            if(user and ws.id==invitation.kws_id):
                c.invitation = invitation
                c.user = user
                c.workspace = ws
                conf = get_cached_kcd_external_conf_object()
                c.kcd_host = conf.kcd_host
                c.kcd_port = conf.kcd_port
                if ('password' in request.params):
                    c.password = request.params['password']
                    
                if ('user_id' in session):
                    c.password = session['password']
            else:
                errorStr = "User was not invited to this workspace"

        else:
            errorStr = "Invalid email_id or workspace_id"
        
        if errorStr:
            c.errorStr = errorStr
            return render('credentials_file/error.mako')
        else:
            return render('credentials_file/get.mako')
Exemplo n.º 3
0
 def _invite_and_login(self, usr, workspace_id, password):
     invitation = Invitation.get_by(kws_id=workspace_id, inviting_user_id=0, user_id=usr.user_id)
     if invitation:
         email_id = invitation.email_id
     else:
         invitees = []
         invitee = WorkspaceInvitee()
         invitee.email_address = usr.email
         invitee.send_mail = False
         invitees.append(invitee)
         
         kc = KcdClient(get_cached_kcd_external_conf_object())
         #TODO handle kcd errors
         ws_url, invitees_result = kc.invite_users(workspace_id, '', invitees)
         email_id = invitees_result[0].email_id
         
     redirect_to(url('invite_create',workspace_id=workspace_id, email_id=email_id, password=password))
Exemplo n.º 4
0
    def create(self, workspace_id):
        
        email_id = None
        if 'email_id' in request.params:
            email_id = request.params['email_id']
        else:
            abort(403)
        
        ws = c.workspace
        invitation = Invitation.get_by(email_id = email_id)

        if (ws and invitation and ws.id==invitation.kws_id):
            kcd_user = KcdUser.get_by(user_id = invitation.user_id, kws_id = invitation.kws_id)
            if(kcd_user and kcd_user.pwd and ('password' in request.params) and request.params['password']==kcd_user.pwd):            
                self._login(invitation, kcd_user.pwd)
            else:
                ui_flash_error(message="You have not provided a valid password.")
                redirect_to(url('invite_show', workspace_id=workspace_id, email_id=email_id))
        else:
            abort(403)