-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandlers.py
More file actions
66 lines (46 loc) · 1.8 KB
/
handlers.py
File metadata and controls
66 lines (46 loc) · 1.8 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
from google.appengine.ext.webapp import template
import webapp2
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import users
from google.appengine.ext import db
import hashlib
from utils import *
#not using sessions tables as of yet.
class Login(webapp2.RequestHandler):
def get(self):
user=get_current_user(self)
if user:
self.redirect('/home')
self.redirect('/')
def post(self):
user=get_current_user(self)
if not user:
username=self.request.get('username')
password=self.request.get('password')
user = UserProfile.all()
user.filter("username =", username)
user.get()
hash_password=hashlib.new()
if hash_password.update(password).hexdigest() == user.password:
set_cookie(self.response, "placementq", str(user.uid), expires=time.time() + 30 * 86400)
self.redirect('/home')
else:
self.redirect('/home')
'''set_cookie(self.response, "placementq", "", expires=time.time() - 30 * 86400)
self.redirect('/')'''
class Register(webapp2.RequestHandler):
def get(self):
user=get_current_user(self)
if user:
self.redirect('/home')
self.response.out.write(template.render("templates/register.html", None))
def post(self):
user=get_current_user(self)
if not user:
success = handle_registration(self)
if success:
self.redirect('/home')
else:
self.redirect('/')
else:
self.redirect('/home')