def default_user_login(self): """ Used in template tags to log in a user. """ if self.username != settings.ALFRESCO_DEFAULT_USER: # TODO: If user is not default direct them to login page # get ticket and return it. return None from alfresco.service import login ticket = login(settings.ALFRESCO_DEFAULT_USER, settings.ALFRESCO_DEFAULT_USER_PASSWORD) self.ticket = ticket self.save() return ticket
def default_user_login(self): """ Used in template tags to log in a user. """ if self.username != settings.ALFRESCO_DEFAULT_USER: # TODO: If user is not default direct them to login page # get ticket and return it. return None from alfresco.service import login ticket = login(settings.ALFRESCO_DEFAULT_USER, settings.ALFRESCO_DEFAULT_USER_PASSWORD) self.ticket = ticket self.save() return ticket
def authenticate(self, username=None, password=None): user = None try: user = AlfrescoUser.objects.get(username=username) except: #if no user exists it will create one pass try: alf_ticket = service.login(username, password) except service.AlfrescoException, a: if a.code is not 2: return None #If alfresco is down we want to tell the user. raise a
def authenticate(self, username=None, password=None): user = None try: user = AlfrescoUser.objects.get(username=username) except: #if no user exists it will create one pass try: alf_ticket = service.login(username, password) except service.AlfrescoException, a: if a.code is not 2: return None #If alfresco is down we want to tell the user. raise a
def get_external_user_ticket(): """ For external sites that use django to serve content we don't want to have them get a ticket everytime. let's keep one around for awhile. """ from alfresco.service import login, AlfrescoException KEY = 'alfresco.utils.get_external_user_ticket.ticket' ticket = cache.get(KEY) if not ticket: try: ticket = login(ALFRESCO_DEFAULT_USER, ALFRESCO_DEFAULT_USER_PASSWORD) except AlfrescoException: #No need to log, login does that. return None cache.set(KEY, ticket, ALFRESCO_EXTERNAL_USER_CACHE_TIME_OUT) return ticket
def get_external_user_ticket(): """ For external sites that use django to serve content we don't want to have them get a ticket everytime. let's keep one around for awhile. """ KEY = 'alfresco.utils.get_external_user_ticket.ticket' ticket = cache.get(KEY) if not ticket: try: ticket = login(ALFRESCO_DEFAULT_USER, ALFRESCO_DEFAULT_USER_PASSWORD) except AlfrescoException: #No need to log, login does that. return None cache.set(KEY, ticket, ALFRESCO_EXTERNAL_USER_CACHE_TIME_OUT) return ticket
def setUp(self): self.ticket = service.login(settings.ALFRESCO_DEFAULT_USER, settings.ALFRESCO_DEFAULT_USER_PASSWORD)
def setUp(self): self.ticket = service.login(settings.ALFRESCO_DEFAULT_USER, settings.ALFRESCO_DEFAULT_USER_PASSWORD)