Exemple #1
0
 def test_pages_as_newuser(self):
     api.user_create(api.ROOT,
                     nick='mmmm',
                     password='******',
                     first_name='m',
                     last_name='m')
     for page in ('/user/root', '/user/mmmm/overview',
                  '/user/mmmm/contacts', '/user/mmmm/followers',
                  '/user/mmmm', '/channel/popular',
                  '/channel/popular/presence/13345'):
         r = self.login_and_get('mmmm', page, password='******')
         self.assertEqual(r.status_code, 200,
                          page + ' failed:' + str(r.status_code))
Exemple #2
0
 def test_pages_as_newuser(self):
   api.user_create(api.ROOT, nick = 'mmmm', password = '******',
                   first_name = 'm',
                   last_name ='m')
   for page in ('/user/root',
                '/user/mmmm/overview',
                '/user/mmmm/contacts',
                '/user/mmmm/followers',
                '/user/mmmm',
                '/channel/popular',
                '/channel/popular/presence/13345'):
     r = self.login_and_get('mmmm', page, password='******')
     self.assertEqual(r.status_code, 200, page + ' failed:' +
                      str(r.status_code))
Exemple #3
0
  def promote_user(self, from_jid, nick):
    ji_ref = api.actor_lookup_im(api.ROOT, from_jid.base())
    if jid_ref:
      # TODO(tyler): Should we tell the user who they are?
      raise exception.ValidationError(
          "You already have an account and are signed in.")

    if not NICK_RE.match(nick):
      raise exception.ValidationError(
          "Invalid screen name, can only use letters or numbers, 3 to 16 "
          "characters")

    # Create the user.  (user_create will check to see if the account has
    # already been created.)
    password = util.generate_uuid()[:8]

    # TODO(termie): Must have a first/last name. :(
    actor = api.user_create(api.ROOT, nick=nick, password=password,
                            given_name=nick, family_name=nick)

    # link this im account to the user's account (equivalent of SIGN IN)
    self.sign_in(from_jid, nick, password)

    # Inform the user of their new password
    welcome = '\n'.join([HELP_WELCOME_NICK % nick,
                         HELP_PASSWORD % password,
                         HELP_POST,
                         HELP_CHANNEL_POST,
                         HELP_COMMENT,
                         HELP_FOLLOW,
                         HELP_STOP,
                         HELP_MORE,
                         HELP_FOOTER])

    self.send_message([from_jid], welcome)
Exemple #4
0
    def promote_user(self, from_jid, nick):
        ji_ref = api.actor_lookup_im(api.ROOT, from_jid.base())
        if jid_ref:
            # TODO(tyler): Should we tell the user who they are?
            raise exception.ValidationError(
                "You already have an account and are signed in.")

        if not NICK_RE.match(nick):
            raise exception.ValidationError(
                "Invalid screen name, can only use letters or numbers, 3 to 16 "
                "characters")

        # Create the user.  (user_create will check to see if the account has
        # already been created.)
        password = util.generate_uuid()[:8]

        # TODO(termie): Must have a first/last name. :(
        actor = api.user_create(api.ROOT,
                                nick=nick,
                                password=password,
                                given_name=nick,
                                family_name=nick)

        # link this im account to the user's account (equivalent of SIGN IN)
        self.sign_in(from_jid, nick, password)

        # Inform the user of their new password
        welcome = '\n'.join([
            HELP_WELCOME_NICK % nick, HELP_PASSWORD % password, HELP_POST,
            HELP_CHANNEL_POST, HELP_COMMENT, HELP_FOLLOW, HELP_STOP, HELP_MORE,
            HELP_FOOTER
        ])

        self.send_message([from_jid], welcome)
 def create_djangouser_for_user(cls, user):
   from common import api
   actor_ref = api.actor_lookup_email(api.ROOT, user.email()) 
   if actor_ref:
     return actor_ref
   params = {'nick': user.nickname(), 'password': "******", 'first_name': user.nickname(),  'last_name': user.nickname()}
   actor_ref = api.user_create(api.ROOT, **params)
   actor_ref.access_level = "delete"
   relation_ref = api.email_associate(api.ROOT, actor_ref.nick, user.email())
   api.post(actor_ref, 
            nick=actor_ref.nick, 
            message='Joined %s!' % (settings.SITE_NAME),
            icon='jaiku-new-user')
   return actor_ref
Exemple #6
0
def user_create(service, params, username="", id="", remote_url=""):
    logging.info("user_create")
    actor_ref = api.user_create(api.ROOT, **params)
    actor_ref.access_level = "delete"

    api.post(actor_ref, nick=actor_ref.nick, message="Joined %s!" % (util.get_metadata("SITE_NAME")))

    email = params.get("email", None)
    if email is not None:
        api.email_associate(api.ROOT, actor_ref.nick, email)
    else:
        key = "emailneeded_%s" % util.display_nick(actor_ref.nick)
        memcache.client.set(key, True, 360)

    key = "firsttime_%s" % util.display_nick(actor_ref.nick)
    memcache.client.set(key, True, 360)

    external_profile_ref = api.create_external_profile(actor_ref.nick, service, username, id, remote_url)

    return actor_ref
Exemple #7
0
def join_join(request):
  if request.user:
    raise exception.AlreadyLoggedInException()

  redirect_to = request.REQUEST.get('redirect_to', '/')

  # get the submitted vars
  nick = request.REQUEST.get('nick', '')
  first_name = request.REQUEST.get('first_name', '')
  last_name = request.REQUEST.get('last_name', '')
  email = request.REQUEST.get('email', '')
  password = request.REQUEST.get('password', '')
  confirm = request.REQUEST.get('confirm', '')
  homepage = request.REQUEST.get('homepage', '')
  hide = request.REQUEST.get('hide', '')

  if request.POST:
    try:
      # TODO validate
      params = util.query_dict_to_keywords(request.POST)

      if hide:
        params['privacy'] = 2
 
      validate.email(email)
      if not mail.is_allowed_to_send_email_to(email):
        raise exception.ValidationError("Cannot send email to that address")

      # TODO start transaction
      if api.actor_lookup_email(api.ROOT, email):
        raise exception.ValidationError(
            'That email address is already associated with a member.')
    
      actor_ref = api.user_create(api.ROOT, **params)
      actor_ref.access_level = "delete"

      api.post(actor_ref, 
               nick=actor_ref.nick, 
               message='Joined %s!' % (settings.SITE_NAME),
               icon='jaiku-new-user')

      # send off email confirmation
      api.activation_request_email(actor_ref, actor_ref.nick, email)
      
      # TODO end transaction
  
      welcome_url = util.qsa('/welcome', {'redirect_to': redirect_to})

      # NOTE: does not provide a flash message
      response = http.HttpResponseRedirect(welcome_url)
      user.set_user_cookie(response, actor_ref)
      return response
    except:
      exception.handle_exception(request)

  # for legal section
  legal_component = component.include('legal', 'dummy_legal')
  legal_html = legal_component.embed_join()

  # for sidebar
  sidebar_green_top = True

  area = "join"
  c = template.RequestContext(request, locals())

  t = loader.get_template('join/templates/join.html')
  return http.HttpResponse(t.render(c))
Exemple #8
0
def join_join(request):
  if request.user:
    raise exception.AlreadyLoggedInException()

  redirect_to = request.REQUEST.get('redirect_to', '/')

  account_types = api.get_config_values(api.ROOT, 'account_type')

  # get the submitted vars
  nick = request.REQUEST.get('nick', '');
  first_name = request.REQUEST.get('first_name', '');
  last_name = request.REQUEST.get('last_name', '');
  email = request.REQUEST.get('email', '');
  password = request.REQUEST.get('password', '');
  confirm = request.REQUEST.get('confirm', '');
  hide = request.REQUEST.get('hide', '');
  country_tag = request.REQUEST.get('country_tag', '')

  if request.POST:
    try:
      # TODO validate
      params = util.query_dict_to_keywords(request.POST)

      if hide:
        params['privacy'] = 2

      # XXX: Check if the data come from a openid account
      # @author: [email protected]
      fromopenid = request.POST.get('fromopenid', False) and True
      if fromopenid:
        try:
          person = openidgae.get_current_person(request, http.HttpResponse())
        except:
          raise exception.ServiceError
        
        email = person.get_email()
        if email == params['email']:
          params['password'] = util.generate_password()
        else:
          raise exception.ServiceError

      # ENDXXX

      validate.email(email)
      if not mail.is_allowed_to_send_email_to(email):
        raise exception.ValidationError("Cannot send email to that address")

      # TODO start transaction
      if api.actor_lookup_email(api.ROOT, email):
        raise exception.ValidationError(
            'That email address is already associated with a member.')
      
      actor_ref = api.user_create(api.ROOT, **params)
      actor_ref.access_level = "delete"

      api.post(actor_ref, 
               nick=actor_ref.nick, 
               message='Joined %s!' % (util.get_metadata('SITE_NAME')))
      if fromopenid:
        api.email_associate(api.ROOT, actor_ref.nick, email)
      else:
        # send off email confirmation
        api.activation_request_email(actor_ref, actor_ref.nick, email)

      logging.info('setting firsttime_%s from register page' % actor_ref.nick)
      memcache.client.set('firsttime_%s' % nick, True)
      # TODO end transaction
      welcome_url = util.qsa('/', {'redirect_to': redirect_to})

      # NOTE: does not provide a flash message
      response = http.HttpResponseRedirect(welcome_url)
      user.set_user_cookie(response, actor_ref)
      return response
    except:
      exception.handle_exception(request)

  # for legal section
  legal_component = component.include('legal', 'dummy_legal')
  legal_html = legal_component.embed_join()
  
  # for sidebar
  sidebar_green_top = True

  area = "join"
  c = template.RequestContext(request, locals())

  t = loader.get_template('join/templates/join.html')
  return http.HttpResponse(t.render(c))
Exemple #9
0
def join_join(request):
    if request.user:
        raise exception.AlreadyLoggedInException()

    redirect_to = get_clean_redirect(request)

    # get the submitted vars
    nick = request.REQUEST.get('nick', '')
    first_name = request.REQUEST.get('first_name', '')
    last_name = request.REQUEST.get('last_name', '')
    email = request.REQUEST.get('email', '')
    password = request.REQUEST.get('password', '')
    confirm = request.REQUEST.get('confirm', '')
    homepage = request.REQUEST.get('homepage', '')
    hide = request.REQUEST.get('hide', '')

    if request.POST:
        try:
            # TODO validate
            params = util.query_dict_to_keywords(request.POST)

            if hide:
                params['privacy'] = 2

            validate.email(email)
            if not mail.is_allowed_to_send_email_to(email):
                raise exception.ValidationError(
                    "Cannot send email to that address")

            # TODO start transaction
            if api.actor_lookup_email(api.ROOT, email):
                raise exception.ValidationError(
                    'That email address is already associated with a member.')

            actor_ref = api.user_create(api.ROOT, **params)
            actor_ref.access_level = "delete"

            api.post(actor_ref,
                     nick=actor_ref.nick,
                     message='Joined %s!' % (settings.SITE_NAME),
                     icon='jaiku-new-user')

            # send off email confirmation
            api.activation_request_email(actor_ref, actor_ref.nick, email)

            # TODO end transaction

            welcome_url = util.qsa('/welcome', {'redirect_to': redirect_to})

            # NOTE: does not provide a flash message
            response = http.HttpResponseRedirect(welcome_url)
            user.set_user_cookie(response, actor_ref)
            return response
        except:
            exception.handle_exception(request)

    # for legal section
    legal_component = component.include('legal', 'dummy_legal')
    legal_html = legal_component.embed_join()

    # for sidebar
    sidebar_green_top = True

    area = "join"
    c = template.RequestContext(request, locals())

    t = loader.get_template('join/templates/join.html')
    return http.HttpResponse(t.render(c))