예제 #1
0
def login(username, password):
    
    dbs = db_session(close=True)
    user = dbs.query(User).filter(User.username == username).first()


    if user and user.password == password:
        ws = web_session()
        ws['username'] = username
        ws['user_id'] = user.id
        return "success"

    return "fail"
예제 #2
0
def doLogin():
    '''Login'''

    post = request.POST.decode()

    form = forms.LoginForm(post)
    dbs = db_session(close=True)

    username = post['username'].strip()
    password = post['password']
    user = dbs.query(User).filter(User.username == username).first()


    if user and user.password == password:
        ws = web_session()
        ws['username'] = username
        ws['user_id'] = user.id
        return "success"
        #return json.dumps({"output" : "success"})


    return "fail"