예제 #1
0
 def get_current_user(cls, app):
     """
     A method to obtain current login user.
     It returns None when no user is logging in.
     """
     tuser = TwitterOAuth.get_user(app.get_controller())
     if tuser:
         user = User.get_user(tuser['nickname'])
         return user
     return None
예제 #2
0
def login():
    """
    A function to perform login to post images.
    """
    tuser = TwitterOAuth.get_user(app.get_controller())
    user = User.get_current_user(app)
    if not user:
        user = User(username = tuser['nickname'])
    user.name = tuser['realname']
    user.profile_image_url = tuser['icon_url']
    user.put()
    app.session['message'] = 'logged in'
    app.session.put()
    app.redirect('/')