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()
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()
def role_loader(user_id, request): result = DBSession.query(User.Role).filter(User.id==user_id).one() transaction.commit() return result
def role_loader(user_id, request): result = DBSession.query(User.Role).filter(User.id == user_id).one() transaction.commit() return result