3 from Products
.CMFCore
.utils
import getUtilityByInterfaceName
4 from Products
.CMFCore
.utils
import getToolByName
5 from Products
.CMFDefault
.utils
import decode
6 from ZTUtils
import make_query
as mq
7 from Products
.CMFDefault
.utils
import Message
as _
9 mtool
= getToolByName(script
, 'portal_membership')
10 ptool
= getUtilityByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
11 stool
= getToolByName(script
, 'portal_skins')
12 utool
= getToolByName(script
, 'portal_url')
13 atool
= getToolByName(script
, 'portal_actions')
15 portal
= utool
.getPortalObject()
18 if stool
.updateSkinCookie():
19 context
.setupCurrentSkin()
24 isAnon
= mtool
.isAnonymousUser()
26 context
.REQUEST
.RESPONSE
.expireCookie('__ac', path
='/')
27 options
['is_anon'] = True
28 options
['title'] = _(u
'Login failure')
29 options
['admin_email'] = ptool
.getProperty('email_from_address')
31 mtool
.createMemberArea()
32 member
= mtool
.getAuthenticatedMember()
33 now
= context
.ZopeTime()
34 last_login
= member
.getProperty('login_time', None)
35 member
.setProperties(last_login_time
=last_login
, login_time
=now
)
36 is_first_login
= (last_login
== '2000/01/01' and
37 ptool
.getProperty('validate_email'))
39 member
.setProperties(last_login_time
='1999/01/01', login_time
=now
)
40 target
= '%s/password_form' % portal_url
41 context
.REQUEST
.RESPONSE
.redirect(target
)
44 member
.setProperties(last_login_time
=last_login
, login_time
=now
)
45 came_from
= context
.REQUEST
.get('came_from', None)
47 return context
.REQUEST
.RESPONSE
.redirect(came_from
)
49 url
= atool
.getActionInfo('user/logged_in', object=portal
)['url']
50 url
= '%s?%s' %(url
, mq(portal_status_message
=_('Login success')))
51 return context
.REQUEST
.RESPONSE
.redirect(url
)
53 return context
.logged_in_template(**decode(options
, script
))