summaryrefslogtreecommitdiff
path: root/docs/quick_tutorial
diff options
context:
space:
mode:
Diffstat (limited to 'docs/quick_tutorial')
-rw-r--r--docs/quick_tutorial/authentication/tutorial/views.py15
-rw-r--r--docs/quick_tutorial/authorization/tutorial/views.py15
2 files changed, 22 insertions, 8 deletions
diff --git a/docs/quick_tutorial/authentication/tutorial/views.py b/docs/quick_tutorial/authentication/tutorial/views.py
index 240a23d3e..ab46eb2dd 100644
--- a/docs/quick_tutorial/authentication/tutorial/views.py
+++ b/docs/quick_tutorial/authentication/tutorial/views.py
@@ -1,4 +1,9 @@
from pyramid.httpexceptions import HTTPFound
+from pyramid.security import (
+ remember,
+ forget,
+ )
+
from pyramid.view import (
view_config,
view_defaults
@@ -36,8 +41,9 @@ class TutorialViews:
login = request.params['login']
password = request.params['password']
if USERS.get(login) == password:
- request.remember_userid(login)
- return HTTPFound(location=came_from)
+ headers = remember(request, login)
+ return HTTPFound(location=came_from,
+ headers=headers)
message = 'Failed login'
return dict(
@@ -52,6 +58,7 @@ class TutorialViews:
@view_config(route_name='logout')
def logout(self):
request = self.request
- request.forget_userid()
+ headers = forget(request)
url = request.route_url('home')
- return HTTPFound(location=url)
+ return HTTPFound(location=url,
+ headers=headers)
diff --git a/docs/quick_tutorial/authorization/tutorial/views.py b/docs/quick_tutorial/authorization/tutorial/views.py
index 2ce2c37b4..43d14455a 100644
--- a/docs/quick_tutorial/authorization/tutorial/views.py
+++ b/docs/quick_tutorial/authorization/tutorial/views.py
@@ -1,4 +1,9 @@
from pyramid.httpexceptions import HTTPFound
+from pyramid.security import (
+ remember,
+ forget,
+ )
+
from pyramid.view import (
view_config,
view_defaults,
@@ -38,8 +43,9 @@ class TutorialViews:
login = request.params['login']
password = request.params['password']
if USERS.get(login) == password:
- request.remember_userid(login)
- return HTTPFound(location=came_from)
+ headers = remember(request, login)
+ return HTTPFound(location=came_from,
+ headers=headers)
message = 'Failed login'
return dict(
@@ -54,6 +60,7 @@ class TutorialViews:
@view_config(route_name='logout')
def logout(self):
request = self.request
- request.forget_userid()
+ headers = forget(request)
url = request.route_url('home')
- return HTTPFound(location=url)
+ return HTTPFound(location=url,
+ headers=headers)