def shortcut_login(self, **credentials):
user = authenticate(**credentials)
if not user:
raise ValueError("User {0} was not authenticated".format(user))
session_auth_hash = ''
if hasattr(user, 'get_session_auth_hash'):
session_auth_hash = user.get_session_auth_hash()
# Mimicking django.contrib.auth functionality
self.set_session_data({AUTH_ID_SESSION_KEY: user.pk,
AUTH_HASH_SESSION_KEY: session_auth_hash,
AUTH_BACKEND_SESSION_KEY: user.backend})
评论列表
文章目录