コード例 #1
0
ファイル: login.py プロジェクト: poyhsiao/betapyweb
def login(username = None, password = None, success = '/main/', fail = '/'):
    # login into the site
    import ml_w_login
    res = ml_w_login.get(username, password)
    if not res[0]:
        # login success
        raise _.HTTPRedirect(success)
    else:
        # login fail
        raise _.HTTPRedirect(fail)
コード例 #2
0
	def test_login_g01(self):
		""" login_g01 """
		if "json" == ml_system.CFG_TYPE:
			shutil.copyfile(os.path.join("unittest", "login-g01.json"), os.path.join("running", "account.txt"))
		if "jcfg" == ml_system.CFG_TYPE:
			shutil.copyfile(os.path.join("unittest", "login-g01.jcfg"), os.path.join("running", "account.txt"))
		if "pickle" == ml_system.CFG_TYPE:
			return
		self.maxDiff = None
		e = ml_w_login.get("admin", "1234", threading.RLock())
		self.assertEqual(e, (True, None))
コード例 #3
0
ファイル: doLogin.py プロジェクト: poyhsiao/betapyweb
    def index(self, **kwargs):
        # print kwargs
        username = kwargs['AccountAlias']
        password = kwargs['Password']
        lang = kwargs['Language']

        _.session['LANG'] = lang
        # save perfer language first

        import ml_w_login as wlogin
        login = wlogin.get(username = username, password = password)
        libs.tools.v(login)
        if login[0]:

            import ml_w_account as wa

            _.session['headers'] = _.request.headers
            _.session['username'] = username
            _.session['password'] = password

            libs.tools.v(username)
            dat = wa.get(user = username)
            libs.tools.v(dat)

            dat = wa.get(user = username)[1]['user']
            for v in dat:
                if username == v["name"]:
                    for kk, vv in v.items():
                        _.session[kk] = vv

            libs.tools.v(_.session.items())

            raise _.HTTPRedirect('/main/')
            # tpl = env.get_template('default.html')
            # return tpl.render(userinfo=_.session)
            # import ml_w_login
            # res = ml_w_login.get(username=username, password=password)
            # print res
            # if not res[0]:
            #     raise _.HTTPRedirect('/')
            # else:
            #     raise _.HTTPRedirect('/main')
        else:
            raise _.HTTPRedirect('/')