forked from yyaoza/vastriver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalid.py
117 lines (79 loc) · 2.61 KB
/
valid.py
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from database import db_search_userid, db_check_userid_with_sid, send_json
from flask import request
def valid_token_id(valid=True):
if valid:
if 'authToken' in request.args and request.args['authToken'] == 's3cr3tV4lu3':
return True
else:
return False
else:
return send_json('INVALID_TOKEN_ID')
def valid_user(valid=True):
if valid:
request_data = request.get_json(force=True)
if 'userId' in request_data:
return request_data['userId']
else:
return False
else:
return send_json('INVALID_PARAMETER')
def match_userid_sid(valid=True):
if valid:
request_data = request.get_json(force=True)
if db_search_userid(request_data['userId']):
return request_data['userId']
else:
return False
else:
return send_json('INVALID_PARAMETER')
def valid_check_user(userid, uuid):
request_data = request.get_json(force=True)
if db_check_userid_with_sid(userid, request_data['sid']):
return send_json("OK", request_data['sid'], uuid)
else:
return send_json('INVALID_PARAMETER')
def valid_uuid(valid=True):
if valid:
request_data = request.get_json(force=True)
if 'uuid' in request_data:
return request_data['uuid']
else:
return False
else:
return send_json('INVALID_PARAMETER')
def valid_sid(valid=True):
if valid:
request_data = request.get_json(force=True)
return 'sid' in request_data
else:
return send_json('INVALID_SID')
def valid_channel(valid=True):
if valid:
request_data = request.get_json(force=True)
return 'channel' in request_data and 'type' in request_data['channel']
else:
return send_json('INVALID_PARAMETER')
def valid_game(valid=True):
if valid:
request_data = request.get_json(force=True)
return 'game' in request_data
else:
return send_json('INVALID_PARAMETER')
def valid_currency(valid=True):
if valid:
request_data = request.get_json(force=True)
return 'currency' in request_data
else:
return send_json('INVALID_PARAMETER')
def valid_transaction(valid=True):
if valid:
request_data = request.get_json(force=True)
return 'transaction' in request_data
else:
return send_json('INVALID_PARAMETER')
def valid_amount(valid=True):
if valid:
request_data = request.get_json(force=True)
return 'amount' in request_data['transaction']
else:
return send_json('INVALID_PARAMETER')