python - Add remember headers to json response using json renderer -
this current way utilize add together remeber headers response:
@view_config(route_name='login', renderer='json', request_method='post') def post_login(request): ... ... authentication logic ... headers = remeber(request, login) homecoming httpfound(location=came_from, headers=headers)
but js waiting response {successful: true, message: 'auth ok'}. httpfound redirect came_from. want js redirect
so tried this
@view_config(route_name='login', renderer='json', request_method='post') def post_login(request): ... ... authentication logic ... homecoming { 'successful': true, 'message': 'auth ok'}
but since remeber headers never added response never authenticated on other side of moooon.
so question how add together remeber headers using json renderer?
you can set info on response directly, documented in vary attributes of rendered responses section of pyramid manual:
@view_config(route_name='login', renderer='json', request_method='post') def post_login(request): ... ... authentication logic ... headers = remeber(request, login) request.response.headerlist.extend(headers) homecoming { 'successful': true, 'message': 'auth ok'}
python json authentication pyramid
No comments:
Post a Comment