コード例 #1
0
ファイル: invite.py プロジェクト: Emamatcyber90/Desio
    def _handle_invite(self, id=None, **k):

        invite = api.invite.get(id)
        if not invite: abort(404)

        url = None

        if invite.status == STATUS_PENDING:

            url = self._get_url(invite)
            user = auth.get_user()

            if not user:

                #check to see if this guy exists already
                user = invite.invited_user or self._get_user(
                    invite.invited_email)
                if user:
                    self.flush()
                    auth.authenticate(user.username,
                                      request.params.get('password'), False)
                else:
                    params = extract(request.params, 'name', 'password',
                                     'confirm_password', 'default_timezone')
                    params['email'] = params['username'] = invite.invited_email

                    logger.info('No user, creating one with %s' % params)

                    user = api.user.create(**params)
                    self.flush()

                    auth.login(user, False)

            else:
                logger.info('User already logged in %s, not creating' % (user))

            if user and user.email.lower() == invite.invited_email.lower():
                logger.info('Accepting Invite %s as %s' % (invite, user))
                api.invite.accept(user, user, invite)
            else:
                raise exceptions.ClientException('Logout Please',
                                                 exceptions.INVALID)

            self.commit()

        logger.info('Accept invite: redirecting to %s' % url)
        return {'url': url or '/'}
コード例 #2
0
ファイル: create.py プロジェクト: Nullicopter/Desio
 def _do_create(self, **kw):
     user_params = extract(request.params, 'name', 'email', 'password', 'confirm_password', 'default_timezone')
     user = api.user.create(**user_params)
     
     org_params = {
         'company_name': request.params.get('company_name'),
         'subdomain': request.params.get('subdomain')
     }
     org = api.organization.create(user, user, **org_params)
     
     self.commit()
     
     email.send(user, 'new_organization.txt', {
         'organization': org
     })
     
     return {'url': auth.login(user) or pylons.config.get('subdomain_url') % (org.subdomain)}
コード例 #3
0
ファイル: invite.py プロジェクト: Nullicopter/Desio
 def _handle_invite(self, id=None, **k):
     
     invite = api.invite.get(id)
     if not invite: abort(404)
     
     url = None
     
     if invite.status == STATUS_PENDING:
         
         url = self._get_url(invite)
         user = auth.get_user()
         
         if not user: 
             
             #check to see if this guy exists already
             user = invite.invited_user or self._get_user(invite.invited_email)
             if user:
                 self.flush()
                 auth.authenticate(user.username, request.params.get('password'), False)
             else:
                 params = extract(request.params, 'name', 'password', 'confirm_password', 'default_timezone')
                 params['email'] = params['username'] = invite.invited_email
                 
                 logger.info('No user, creating one with %s' % params)
                 
                 user = api.user.create(**params)
                 self.flush()
                 
                 auth.login(user, False)
             
         else:
             logger.info('User already logged in %s, not creating' % (user))
         
         if user and user.email.lower() == invite.invited_email.lower():
             logger.info('Accepting Invite %s as %s' % (invite, user))
             api.invite.accept(user, user, invite)
         else:
             raise exceptions.ClientException('Logout Please', exceptions.INVALID)
         
         self.commit()
     
     logger.info('Accept invite: redirecting to %s' % url)
     return {'url': url or '/'}
コード例 #4
0
ファイル: create.py プロジェクト: Emamatcyber90/Desio
    def _do_create(self, **kw):
        user_params = extract(request.params, 'name', 'email', 'password',
                              'confirm_password', 'default_timezone')
        user = api.user.create(**user_params)

        org_params = {
            'company_name': request.params.get('company_name'),
            'subdomain': request.params.get('subdomain')
        }
        org = api.organization.create(user, user, **org_params)

        self.commit()

        email.send(user, 'new_organization.txt', {'organization': org})

        return {
            'url':
            auth.login(user)
            or pylons.config.get('subdomain_url') % (org.subdomain)
        }