-
Notifications
You must be signed in to change notification settings - Fork 2
/
login.py
executable file
·31 lines (16 loc) · 908 Bytes
/
login.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
import webapp2
import json
from main import *
from api import hitapi
#This page follows the instructions at http://wiki.warlight.net/index.php/CLOT_Authentication
class LoginPage(BaseHandler):
def get(self):
#Cast token to long to ensure the only contain numerical digits (this is easy in python since longs can go to any size. In other languages we might have to do more work here to avoid overflows since tokens can exceed 2^32)
token = str(long(self.request.GET['token']))
clotpass = self.request.GET['clotpass']
apiret = json.loads(hitapi('/API/ValidateInviteToken', { 'Token': token }))
if clotpass != apiret['clotpass']:
return self.redirect('/loginfailed')
self.session_store = sessions.get_store(request=self.request)
self.session['authenticatedtoken'] = token
self.redirect('/' + self.request.GET['state'])