Esempio n. 1
0
 def post(self):
   username = handy.escape(self.get_argument('username'))
   username = handy.slugify(username)
   password = self.get_argument('password')
   password = handy.passwd(username, password)
   m = Member(username=username, password=password)
   is_saved = m.put()
   if is_saved:
     return self.redirect('/login')
   return self.redirect('/register?err=1')
Esempio n. 2
0
 def wrapper(self, *args, **kwargs):
   user = self.get_cookie('twidder', secret=self.application.cookie_secret)
   if not user:
     return self.render_error(self.AUTH_FAILURE)
   is_user = Member.get(username=user)
   if not is_user:
     return self.render_error(self.AUTH_FAILURE)
   return func(self, *args, **kwargs)
Esempio n. 3
0
def addmsg(jsoned):
  msg = jsoned['message']
  user = jsoned['username']
  msg = handy.escape(msg)
  msg_html = handy.TextParser.parser(msg)
  user_id = Member.get(username=user).user_id
  msg_set = Message(user=user_id, message=msg, message_html=msg_html)
  is_saved = msg_set.put()
  return is_saved
Esempio n. 4
0
 def get(self, user):
   user = Member.get(user)
   if not user:
     return self.render_error(self._NOT_FOUND)
   user_id = user.user_id
   following = Friend.count_followings(user_id)
   follower = Friend.count_followers(user_id)
   messages = Message.get_user_messages(user_id)
   username = user.username
   return self.render2('user.html', following=following, follower=follower,
                       messages=messages, username=username, title=username)
Esempio n. 5
0
 def post(self):
   username = self.get_argument('username')
   password = self.get_argument('password')
   if not username or not password:
     return self.redirect('/login')
   username = handy.escape(self.get_argument('username'))
   password = handy.passwd(username, password)
   is_exists = Member.exists(username, password)
   if is_exists:
     self.set_cookie('twidder', username,
                     secret=self.application.cookie_secret)
     return self.redirect('/user/%s' % username)
   else:
     return self.redirect('/register')
Esempio n. 6
0
 def get_user(self):
   user = self.get_cookie('twidder', secret=self.application.cookie_secret)
   if user:
     return Member.get(user)
   return None