Esempio n. 1
0
    def __init__(self):

        # Get Environment variables
        self.domain = webnotes.get_env_vars('HTTP_HOST')
        if self.domain and self.domain.startswith('www.'):
            self.domain = self.domain[4:]

        # language
        self.set_lang(webnotes.get_env_vars('HTTP_ACCEPT_LANGUAGE'))

        webnotes.remote_ip = webnotes.get_env_vars('REMOTE_ADDR')

        # load cookies
        webnotes.cookie_manager = CookieManager()

        webnotes.request_method = webnotes.get_env_vars("REQUEST_METHOD")

        # override request method. All request to be of type POST, but if _type == "POST" then commit
        if webnotes.form_dict.get("_type"):
            webnotes.request_method = webnotes.form_dict.get("_type")
            del webnotes.form_dict["_type"]

        # set db
        self.connect()

        # login
        webnotes.login_manager = LoginManager()

        # start session
        webnotes.session_obj = Session()
        webnotes.session = webnotes.session_obj.data

        # check status
        if webnotes.conn.get_global("__session_status") == 'stop':
            webnotes.msgprint(
                webnotes.conn.get_global("__session_status_message"))
            raise webnotes.SessionStopped('Session Stopped')

        # load profile
        self.setup_profile()

        # run login triggers
        if webnotes.form_dict.get('cmd') == 'login':
            webnotes.login_manager.run_trigger('on_login_post_session')

        # write out cookies
        webnotes.cookie_manager.set_cookies()
Esempio n. 2
0
	def __init__(self):

		# Get Environment variables
		self.domain = webnotes.get_env_vars('HTTP_HOST')
		if self.domain and self.domain.startswith('www.'):
			self.domain = self.domain[4:]

		# language
		self.set_lang(webnotes.get_env_vars('HTTP_ACCEPT_LANGUAGE'))
		
		webnotes.remote_ip = webnotes.get_env_vars('REMOTE_ADDR')

		# load cookies
		webnotes.cookie_manager = CookieManager()

		webnotes.request_method = webnotes.get_env_vars("REQUEST_METHOD")
		
		# override request method. All request to be of type POST, but if _type == "POST" then commit
		if webnotes.form_dict.get("_type"):
			webnotes.request_method = webnotes.form_dict.get("_type")
			del webnotes.form_dict["_type"]

		# set db
		self.connect()

		# login
		webnotes.login_manager = LoginManager()

		# start session
		webnotes.session_obj = Session()
		webnotes.session = webnotes.session_obj.data

		# check status
		if webnotes.conn.get_global("__session_status")=='stop':
			webnotes.msgprint(webnotes.conn.get_global("__session_status_message"))
			raise webnotes.SessionStopped('Session Stopped')

		# load profile
		self.setup_profile()

		# run login triggers
		if webnotes.form_dict.get('cmd')=='login':
			webnotes.login_manager.run_trigger('on_login_post_session')

		# write out cookies
		webnotes.cookie_manager.set_cookies()
Esempio n. 3
0
    def __init__(self):

        # Get Environment variables
        self.domain = webnotes.get_env_vars('HTTP_HOST')
        if self.domain and self.domain.startswith('www.'):
            self.domain = self.domain[4:]

        webnotes.remote_ip = webnotes.get_env_vars('REMOTE_ADDR')

        # load cookies
        webnotes.cookie_manager = CookieManager()

        # set db
        self.set_db()

        # check status
        if webnotes.conn.get_global("__session_status") == 'stop':
            webnotes.msgprint(
                webnotes.conn.get_global("__session_status_message"))
            raise Exception

        # -----------------------------
        # start transaction
        webnotes.conn.begin()

        # login
        webnotes.login_manager = LoginManager()

        # start session
        webnotes.session_obj = Session()
        webnotes.session = webnotes.session_obj.data
        webnotes.tenant_id = webnotes.session.get('tenant_id', 0)

        # write out cookies if sid is supplied (this is a pre-logged in redirect)
        if webnotes.form_dict.get('sid'):
            webnotes.cookie_manager.set_cookies()

        # run login triggers
        if webnotes.form_dict.get('cmd') == 'login':
            webnotes.login_manager.run_trigger('on_login_post_session')

        # load profile
        self.setup_profile()

        webnotes.conn.commit()
Esempio n. 4
0
	def __init__(self):

		# Get Environment variables
		self.domain = webnotes.get_env_vars('HTTP_HOST')
		if self.domain and self.domain.startswith('www.'):
			self.domain = self.domain[4:]

		webnotes.remote_ip = webnotes.get_env_vars('REMOTE_ADDR')					

		# load cookies
		webnotes.cookie_manager = CookieManager()

		# set db
		self.set_db()

		# -----------------------------
		# start transaction
		webnotes.conn.begin()

		# login
		webnotes.login_manager = LoginManager()

		# start session
		webnotes.session_obj = Session()
		webnotes.session = webnotes.session_obj.data

		# check status
		if webnotes.conn.get_global("__session_status")=='stop':
			webnotes.msgprint(webnotes.conn.get_global("__session_status_message"))
			raise webnotes.SessionStopped('Session Stopped')


		# write out cookies if sid is supplied (this is a pre-logged in redirect)
		if webnotes.form_dict.get('sid'):
			webnotes.cookie_manager.set_cookies()

		# run login triggers
		if webnotes.form_dict.get('cmd')=='login':
			webnotes.login_manager.run_trigger('on_login_post_session')
			
		# load profile
		self.setup_profile()

		webnotes.conn.commit()