Пример #1
0
    def handler(self, request, path):
        if 'auto_authenticate' in request.session:
            username = request.session['auto_authenticate']
        else:
            if not request.post:
                return self.evaluate_form(session=request.session)
            username = request.post.get('username', '')
            password = request.post.get('password', '')
            if '' in (username, password):
                return self.evaluate_form(session=request.session)

        invalid_login = True
        u = None
        try:
            u = user.User(username)
            invalid_login = False
        except UnknownUserError as e:
            pass

        if 'auto_authenticate' in request.session:
            del request.session['auto_authenticate']
            request.session['change_password_hint'] = True
        else:
            try:
                if not u or not u.check_password(password):
                    return self.evaluate_form(
                        'Not a valid username and password combination')
            except NoMD5PasswordError as e:
                return self.evaluate_form(str(e))

            if invalid_login:
                return self.evaluate_form(
                    'Not a valid username and password combination')

        if not database_isuptodate():
            localvalues = {}
            request.session['upgrade_user'] = True
            base_url = options.url_path('base_url_submin')
            localvalues['base_url'] = str(base_url)
            localvalues['session_user'] = u
            return Response(evaluate('database_upgrade.html', localvalues))

        url = options.url_path('base_url_submin')
        if 'redirected_from' in request.session:
            login_url = options.url_path('base_url_submin') + 'login'
            url = request.session['redirected_from']
            if url.startswith(login_url):
                url = options.url_path('base_url_submin')

        session_user = u.session_object()
        session_user['is_authenticated'] = True
        request.session['user'] = session_user
        request.session.cleanup()

        return Redirect(url, request, store_url=False)
Пример #2
0
	def handler(self, request, path):
		if 'auto_authenticate' in request.session:
			username = request.session['auto_authenticate']
		else:
			if not request.post:
				return self.evaluate_form(session=request.session)
			username = request.post.get('username', '')
			password = request.post.get('password', '')

		invalid_login = True
		u = None
		try:
			u = user.User(username)
			invalid_login = False
		except UnknownUserError as e:
			pass

		if 'auto_authenticate' in request.session:
			del request.session['auto_authenticate']
			request.session['change_password_hint'] = True
		else:
			try:
				if not u or not u.check_password(password):
					return self.evaluate_form('Not a valid username and password combination')
			except NoMD5PasswordError as e:
				return self.evaluate_form(str(e))

			if invalid_login:
				return self.evaluate_form('Not a valid username and password combination')

		if not database_isuptodate():
			localvalues = {}
			request.session['upgrade_user'] = True
			base_url = options.url_path('base_url_submin')
			localvalues['base_url'] = str(base_url)
			localvalues['session_user'] = u
			return Response(evaluate('database_upgrade.html', localvalues))

		url = options.url_path('base_url_submin')
		if 'redirected_from' in request.session:
			login_url = options.url_path('base_url_submin') + 'login'
			url = request.session['redirected_from']
			if url.startswith(login_url):
				url = options.url_path('base_url_submin')

		session_user = u.session_object()
		session_user['is_authenticated'] = True
		request.session['user'] = session_user
		request.session.cleanup()

		return Redirect(url, request, store_url=False)
Пример #3
0
	def handler(self, req, path):
		localvars = {}
		localvars['uptodated'] = True
		localvars['base_url'] = options.url_path('base_url_submin')
		
		if database_isuptodate():
			localvars['alreadyuptodate'] = True
		else:
			database_evolve()
			localvars['alreadyuptodate'] = False

		formatted = evaluate('database_upgrade.html', localvars)

		return Response(formatted)
Пример #4
0
        from submin.models import sessions

        val = json.dumps(self.dict)
        sessions.set(self.key, val, self._expires)

    def cleanup(self):
        from submin.models import sessions

        sessions.cleanup()


SESS_CLASS = DBPickleDict
SESS_INIT_ARG = "_getid"
from submin.models.storage import database_isuptodate

if not database_isuptodate():
    SESS_CLASS = FilePickleDict
    SESS_INIT_ARG = "_getfilename"


class Session(SESS_CLASS):
    def __init__(self, request, autoupdatecookie=True, autosave=True):
        self.request = request
        self.sessionid = self.request.getCookie("SubminSessionID", self.generateSessionID())

        self.__destroyed = False
        init_arg = getattr(self, SESS_INIT_ARG)
        super(Session, self).__init__(init_arg(), autosave)

        if autoupdatecookie:
            self.updateCookie()
Пример #5
0
            sessions.unset(self.key)

    def save(self):
        from submin.models import sessions
        val = json.dumps(self.dict)
        sessions.set(self.key, val, self._expires)

    def cleanup(self):
        from submin.models import sessions
        sessions.cleanup()


SESS_CLASS = DBPickleDict
SESS_INIT_ARG = "_getid"
from submin.models.storage import database_isuptodate
if not database_isuptodate():
    SESS_CLASS = FilePickleDict
    SESS_INIT_ARG = "_getfilename"


class Session(SESS_CLASS):
    def __init__(self, request, autoupdatecookie=True, autosave=True):
        self.request = request
        self.sessionid = self.request.getCookie('SubminSessionID', \
          self.generateSessionID())

        self.__destroyed = False
        init_arg = getattr(self, SESS_INIT_ARG)
        super(Session, self).__init__(init_arg(), autosave)

        if autoupdatecookie: