This repository has been archived by the owner on Feb 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made BaseRequest an IParticipation and replaced request.user with
request.principal everywhere.
- Loading branch information
0 parents
commit 14778b0
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2003 Zope Corporation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. | ||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
# FOR A PARTICULAR PURPOSE. | ||
# | ||
############################################################################## | ||
"""Login and Logout screens | ||
$Id: auth.py,v 1.1 2004/03/14 04:45:00 srichter Exp $ | ||
""" | ||
from zope.interface import implements | ||
from zope.app.publisher.interfaces.http import ILogin, ILogout | ||
from zope.app.security.principalregistry import UnauthenticatedPrincipal | ||
from zope.app.pagetemplate import ViewPageTemplateFile | ||
from zope.proxy import removeAllProxies | ||
|
||
class HTTPAuthenticationLogin(object): | ||
implements(ILogin) | ||
|
||
def login(self, nextURL=None): | ||
"""See zope.app.security.interfaces.ILogin""" | ||
if isinstance(removeAllProxies(self.request.principal), \ | ||
UnauthenticatedPrincipal): | ||
self.request.unauthorized("basic realm='Zope'") | ||
return self.failed() | ||
else: | ||
if nextURL is None: | ||
return self.confirmation() | ||
else: | ||
self.request.response.redirect(nextURL) | ||
|
||
confirmation = ViewPageTemplateFile('login.pt') | ||
|
||
failed = ViewPageTemplateFile('login_failed.pt') | ||
|
||
|
||
class HTTPAuthenticationLogout(object): | ||
"""Since HTTP Authentication really does not know about logout, we are | ||
simply challenging the client again.""" | ||
|
||
implements(ILogout) | ||
|
||
def __init__(self, context, request): | ||
self.context = context | ||
self.request = request | ||
|
||
def logout(self, nextURL=None): | ||
"""See zope.app.security.interfaces.ILogout""" | ||
if not isinstance(self.request.principal, UnauthenticatedPrincipal): | ||
self.request.unauthorized("basic realm='Zope'") | ||
if nextURL: | ||
return self.redirect() | ||
|
||
if nextURL is None: | ||
return self.confirmation() | ||
else: | ||
return self.request.response.redirect(nextURL) | ||
|
||
confirmation = ViewPageTemplateFile('logout.pt') | ||
|
||
redirect = ViewPageTemplateFile('redirect.pt') | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<html metal:use-macro="context/@@standard_macros/page"> | ||
<body> | ||
<div metal:fill-slot="body"> | ||
|
||
<h1 i18n:translate="">Login successful!</h1> | ||
|
||
<p style="font-size: 200%" i18n:translate=""> | ||
You are now logged in as | ||
<em tal:content="view/request/principal/title" | ||
i18n:name="UserTitle">Joe Smith</em>. | ||
</p> | ||
|
||
<a href="." i18n:translate="">Back to the main page.</a> | ||
|
||
</div> | ||
</body> | ||
|
||
</html> |