Exemple #1
0
def login(request): 
    user_id = request.POST.get('user_id', '')
    pwd = request.POST.get('password', '')
    user = DBSession.query(User).filter(User.id==user_id).one()
    if user is not None and user.check_password(pwd):
        claims = {
            "iss": user_id,
        }
        jwt = make_jwt(request, claims)
        response = Response(body='login success', content_type='text/plain')
        remember(response, jwt)
        transaction.commit()
        return response
    else:
        transaction.commit()
        return HTTPUnauthorized()
Exemple #2
0
def login(request):
    user_id = request.POST.get('user_id', '')
    pwd = request.POST.get('password', '')
    user = DBSession.query(User).filter(User.id == user_id).one()
    if user is not None and user.check_password(pwd):
        claims = {
            "iss": user_id,
        }
        jwt = make_jwt(request, claims)
        response = Response(body='login success', content_type='text/plain')
        remember(response, jwt)
        transaction.commit()
        return response
    else:
        transaction.commit()
        return HTTPUnauthorized()
Exemple #3
0
def role_loader(user_id, request):
    result = DBSession.query(User.Role).filter(User.id==user_id).one()
    transaction.commit()
    return result
Exemple #4
0
def role_loader(user_id, request):
    result = DBSession.query(User.Role).filter(User.id == user_id).one()
    transaction.commit()
    return result