示例#1
0
文件: views.py 项目: 0rps/rsoi_course
def handleCheckCookieRequest(request):
	get = request.GET
	token = get.get('token')
	sessionId = get.get('id')

	cookie = models.get_cookie(sessionId, token)
	if cookie:
		loginfo('valid cookie')
		return HttpResponse(json.dumps({'userId': cookie.userId}))
	else:
		loginfo('invalid cookie')
		return HttpResponseBadRequest()
示例#2
0
def handleCheckCookieRequest(request):
	get = request.GET
	token = get.get('token')
	sessionId = get.get('id')

	cookie = models.get_cookie(sessionId, token)
	if cookie:
		loginfo('valid cookie')
		return HttpResponse(json.dumps({'userId': cookie.userId}))
	else:
		loginfo('invalid cookie')
		return HttpResponseBadRequest()
示例#3
0
def handleLogoutRequest(request):
	delete = request.REQUEST

	token = delete.get('token')
	sessionId = delete.get('id')

	loginfo("clear cookie: ")
	loginfo("token: " + token)
	loginfo('id: ' + sessionId)

	cookie = models.get_cookie(sessionId, token)
	if cookie:
		cookie.delete()
		loginfo('cookie deleted')

	return HttpResponse()