-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusr.py
More file actions
83 lines (74 loc) · 3.17 KB
/
Copy pathusr.py
File metadata and controls
83 lines (74 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# User modules
from auth import * # classes: cls
from globvars import *
from log import CUserLog
# reCAPHCHA has origin protection, be sure the hostname is 127.0.0.1 or localhost
# and enable cookies and the cross site script
class PLogin(PAuth):
""" login page handler"""
def get(self, *args, **kwargs):
un = None
try:
if self.hasLoggedin():
self.render('auth.html', color="rgba(255,0,0,0.2)", jump=CTools.jumpJsGen('/game', REDIRECT_TIME),
msg="You have logged in. <br> You will be redirected to Game Lobby page in {0} seconds.".format(
str(REDIRECT_TIME)
))
else:
if DisableCAPTCHA:
s = dict({'h': '', 'i': '', 'b': '', 'c': ''})
else:
s = CRecaptcha.gen()
self.render('login.html',
header_script=s['h'],
inline_script=s['i'],
bottom_script=s['b'],
precheck_script=s['c'])
except Exception as e:
msg = 'Func: {0} Error on {1}, line {2}:{3}'.format(
sys._getframe().f_code.co_name, __file__, sys._getframe().f_lineno, str(e))
slog.e(msg)
rlog.e(msg)
if un is not None:
ulog = CUserLog(un)
ulog.e(msg)
self.send_error()
finally:
rlog.i('Login page request. ip:{0}, username:{1}'.format(
self.request.remote_ip, 'None' if un is None else un))
class PSignUp(PAuth):
""" reg page handler"""
def get(self, *args, **kwargs):
un = None
try:
if self.hasLoggedin():
self.render('auth.html', color="rgba(255,0,0,0.2)", jump=CTools.jumpJsGen('/game', REDIRECT_TIME),
msg="You have logged in. <br> You will be redirected to Game Lobby page in {0} seconds.".format(
str(REDIRECT_TIME)
))
else:
if DisableCAPTCHA:
s = dict({'h': '', 'i': '', 'b': '', 'c': ''})
else:
s = CRecaptcha.gen()
self.render('reg.html',
header_script=s['h'],
inline_script=s['i'],
bottom_script=s['b'],
precheck_script=s['c'])
except Exception as e:
msg = 'Func: {0} Error on {1}, line {2}:{3}'.format(
sys._getframe().f_code.co_name, __file__, sys._getframe().f_lineno, str(e))
slog.e(msg)
rlog.e(msg)
if un is not None:
ulog = CUserLog(un)
ulog.e(msg)
self.send_error()
finally:
rlog.i('Reg page request. ip:{0}, username:{1}'.format(
self.request.remote_ip, 'None' if un is None else un))
if __name__ == "__main__":
d = dict()
d['un'] = 'fffff'
d['pw'] = 'abv1K123_abc'