Exemplo n.º 1
0
  def wrapper(self, *args, **kwargs):
    user = None
    user_id = self.request.get('user_id')
    json_required = gtools.str_to_bool(self.request.get('json_required', 'false'))
    if user_id :
      user = util.get_user_by_id(user_id)
    else:
      user = util.get_active_user()

    if not user:
      logging.error("Not an authorised user")
      if json_required:
        response = {
            "status" : constants.ERROR,
            "data" : None,
            "errors" : {"msg":"unauthorized user", "error":"E403"}
        }
        self.json(response)
        return
      else:
        self.redirect("/artists")
        return

    kwargs['user'] = user
    logging.info("logged in user  ::   %s"%user.username)    
    return _call_method(self, method, *args, **kwargs)
Exemplo n.º 2
0
 def get(self):
     user = util.get_active_user()
     if user:
         if user.is_admin:
             return self.redirect('/admin/user_report')
         return self.redirect('/dashboard')
     pagevars = {'user': user}
     self.redirect('/')
     return
Exemplo n.º 3
0
 def get(self):
     response = self.request.get('response')
     user = util.get_active_user()
     if user:
         if user.is_admin:
             return self.redirect('/admin/user_report')
         return self.redirect('/dashboard')
     self.redirect('/')
     return
Exemplo n.º 4
0
    def get(self):
        user_id = self.request.get('id')
        token = self.request.get('token')

        response = user_component.verify_account(user_id, token)
        response = simplejson.dumps(response)
        user = util.get_active_user()
        if user:
            return self.redirect('/dashboard?response=%s' % response)
        return self.redirect('/?response=%s' % response)
Exemplo n.º 5
0
 def wrapper(self, *args, **kwargs):
   user = util.get_active_user()
   if user:
     is_admin = user.is_admin
     if is_admin:
       kwargs['user'] = user
       return _call_method(self, method, *args, **kwargs)
   msg = 'Admin access required'
   logging.error(msg)
   self.error(403)
   self.redirect("/dashboard?error_message=%s"%msg)
   return
Exemplo n.º 6
0
    def get(self):
        user_id = self.request.get('id')
        token = self.request.get('token')

        if user_id and token:
            response = user_component.remove_confirm(user_id, token)
            if not response['status']:
                response = simplejson.dumps(response)
                if util.get_active_user():
                    return self.redirect('/dashboard?response=%s' % response)
                return self.redirect('/?response=%s' % response)

        page_vars = {'user': None, 'user_id': user_id, 'token': token}
        self.generate("remove_confirm.html", page_vars)
        return
Exemplo n.º 7
0
  def wrapper(self, *args, **kwargs):
    user = None
    user_id = self.request.get('user_id')
    if user_id :
      user = util.get_user_by_id(user_id, load_only_params=True)
    else:
      user = util.get_active_user()

    if not user:
      logging.info("UserAuthenticationRequired")
      self.error(403)
      data = {'status': False, 'errors':{'error': 'UserAuthenticationRequired'}}
      self.json(data)
      return
    kwargs['user'] = user
    logging.info("logged in user  ::   %s"%user.username)
    return _call_method(self, method, *args, **kwargs)
Exemplo n.º 8
0
    def post(self):
        continue_url = self.request.get('continue', '/dashboard')
        host = self.request.get('host')
        page_vars = {
            'email': self.request.get('email', '').strip().lower(),
            'password': self.request.get('password'),
            'device_id': '',
        }
        login_response = user_component.login_user(page_vars)
        if login_response['status']:
            user = util.get_active_user()
            if user.is_admin:
                continue_url = "/admin/user_report"
            self.redirect(util.get_http_domain() + continue_url)
            return

        self.redirect('/?err=1&email=%s' %
                      urllib.quote_plus(page_vars['email']))
        return
Exemplo n.º 9
0
    def get(self):
        user = util.get_active_user()
        response = None
        errors = None
        if user:
            util.delete_active_session(user=user)
        user_id = self.request.get('u_id')
        if user_id:
            user = util.get_user_by_id(user_id)
        token = self.request.get('token')
        if user_id and token:
            response = user_component.verify_reset_password(user, token)
            if response and not response['status']:
                response = simplejson.dumps(response)
                return self.redirect('/artists?response=%s' % response)

        if self.request.get('response'):
            response = simplejson.loads(self.request.get('response'))
        if response and response['errors']:
            errors = response['errors']
        data = {'user': user, 'errors': errors, 'response': response}
        self.generate("reset_password.html", data)
        return
Exemplo n.º 10
0
    def get(self, token_info=None):
        if token_info:
            token_detail = util.get_detail_of_token(token_info)
            self.content_id = token_detail[
                "content_id"] if token_detail.has_key("content_id") else None
            self.post_user_id = token_detail[
                "post_user_id"] if token_detail.has_key(
                    "post_user_id") else None
            self.token = token_detail["token"] if token_detail.has_key(
                "token") else None
            self.post_message = None
        else:
            self.content_id = self.request.get("content_id", None)
            self.post_user_id = self.request.get("post_user_id", None)
            self.token = self.request.get('token', None)
            self.post_message = self.request.get("post_message", None)

        check_valid = self.check_valid_request()
        if not check_valid:
            self.error(404)
            return

        if not self.post_message:
            self.post_message = self.auth_token.message

        user = util.get_active_user()

        follower_ids = util.get_followers_ids(user) if user else []
        split_s3_key = str(self.content.s3_Key).split(".")
        c_format = split_s3_key[-1]
        logging.info("content url format  :: %s" % c_format)
        logging.info("content format  :: %s" % self.content.format)
        content_format = "mp3" if self.content.format == "mp3" and c_format == "mp3" else "mp4"
        content_streaming_url = "rtmp://%s/vods3/_definst_/%s:amazons3/%s/%s" % (
            constants.EC2_DOMAIN_URL, content_format,
            constants.DEFAULT_BUCKET_NAME, self.content.s3_Key)
        logging.info("content url  :: %s" % content_streaming_url)
        post_album_image = boto_lib.get_image_url(
            constants.ALBUM_IMAGES_BUCKET,
            self.content.album.s3_fb_post_image_key
        ) if self.content.album.s3_fb_post_image_key else None

        domain_url = util.get_domain()
        favicon_image_url = domain_url + constants.DEFAULT_VEROMUSE_LOGO
        page_vars = {
            'user':
            user,
            'post_user':
            self.post_user,
            'content':
            self.content,
            'content_streaming_url':
            content_streaming_url,
            's3_content_con_url':
            util.get_s3_host_url(constants.DEFAULT_BUCKET_NAME),
            's3_user_con_url':
            util.get_s3_host_url(constants.USER_IMAGES_BUCKET),
            'post_album_image':
            post_album_image,
            'is_following':
            True if self.post_user.id in follower_ids else False,
            'ios_app_link':
            constants.APPLE_STORE_LINK,
            'play_store_link':
            constants.PLAY_STORE_LINK,
            'facebook_app_id':
            constants.FACEBOOK_APP_ID,
            'post_message':
            self.post_message if self.post_message else '',
            "link_url":
            self.request.url,
            "favicon_image_url":
            favicon_image_url,
            "facebook_meta_image":
            post_album_image if post_album_image else favicon_image_url,
            "facebook_meta_image_height":
            constants.FB_POST_IMAGE_HEIGHT
            if post_album_image else constants.DEFAULT_VLOGO_HEIGHT,
            "facebook_meta_image_width":
            constants.FB_POST_IMAGE_WIDTH
            if post_album_image else constants.DEFAULT_VLOGO_WIDTH,
            "google_play_app_id":
            constants.GOOGLE_PLAY_APP_ID,
            "apple_store_app_id":
            constants.APPLE_STORE_APP_ID,
            'mega_tag_description':
            constants.META_TAG_DESCIPTION,
            'mega_tag_robots':
            constants.META_TAG_ROBOTS,
            'mega_tag_keywords':
            constants.META_TAG_KEYWORDS
        }
        self.generate("facebook_post_redirect.html", page_vars)
        return
Exemplo n.º 11
0
 def get(self):
     user = util.get_active_user()
     if user:
         return self.redirect('/dashboard')
     page_vars = {}
     self.generate('index.html', page_vars)
Exemplo n.º 12
0
    def get(self):
        user = util.get_active_user()
        if user:
            return self.redirect('/dashboard')

        self.generate("forgot_password.html")