Skip to content
Browse files

Validate @dojo e-mails

  • Loading branch information...
1 parent 462fe20 commit e655a07fac95392a4293a7ce4c80542a4dc2f6ba @dustball dustball committed Aug 2, 2013
Showing with 39 additions and 11 deletions.
  1. +5 −0 cron.yaml
  2. +18 −2 main.py
  3. +13 −6 static/signin.js
  4. +3 −3 templates/main.html
View
5 cron.yaml
@@ -4,3 +4,8 @@ cron:
# url: /appreciationemail?sendemail=true
# schedule: every sunday 13:30
# timezone: America/Los_Angeles
+
+- description: cache usersnames
+ url: /cron/fetchusers
+ schedule: every 1 hour
+ timezone: America/Los_Angeles
View
20 main.py
@@ -5,7 +5,7 @@
from google.appengine.api import channel
from google.appengine.api.labs import taskqueue
from google.appengine.ext import webapp
-from google.appengine.api import users
+from google.appengine.api import users, memcache
from google.appengine.ext.webapp import template
from google.appengine.ext import deferred
from google.appengine.ext import db
@@ -224,7 +224,13 @@ def get(self):
payload=self.request.query_string,
method=urlfetch.POST,
headers={'Content-Type': 'application/x-www-form-urlencoded'})
-
+
+ if "@hackerdojo.com" in email:
+ usernames = memcache.get('usernames')
+ username = string.split(email,"@")[0]
+ if usernames and "[" in usernames and username not in usernames:
+ response = {"error": "Member not found", "nomember":"true"}
+
self.response.out.write(json.dumps(response))
# Initializes SigninRecord database (see util.py)
@@ -571,6 +577,15 @@ def to_dict(staffer):
# subject="there@ bounce message",
# body="Sorry, it doesn't look like anyone is signed in as staff right now.")
+class FetchUsersHandler(webapp.RequestHandler):
+ def get(self):
+ resp = urlfetch.fetch('http://domain.hackerdojo.com/users', deadline=20)
+ if resp.status_code == 200:
+ memcache.set('usernames', resp.content, 3600*2)
+ self.response.out.write("200 OK - Usernames set")
+ else:
+ self.response.out.write("500 - Something broke")
+
app = webapp.WSGIApplication([
('/', MainHandler),
('/cc', CCHandler),
@@ -583,6 +598,7 @@ def to_dict(staffer):
('/fast', FastHandler),
('/signin', SigninHandler),
('/staff', StaffHandler),
+ ('/cron/fetchusers', FetchUsersHandler),
('/api/doorlog', DoorLogHandler),
('/api/charge', ChargeHandler),
('/sstats/?', StatHandler),
View
19 static/signin.js
@@ -257,12 +257,19 @@ function ok() {
},
success: function(data) {
$('#ajaxloading').fadeOut();
- $("#thanksmessage").html("<b><nobr>Thanks "+data.name+"!</nobr></b><br/><br/><small>Visit #"+data.signins+"</small>");
- if (data.tos) {
- $('#ajaxloading').hide();
- $('#tos').fadeIn();
- } else {
- thanks();
+
+ if (data.nomember) {
+ $('#denied').fadeIn();
+ setTimeout("$('#denied').fadeOut();",3 * 1000);
+ } else {
+
+ $("#thanksmessage").html("<b><nobr>Thanks "+data.name+"!</nobr></b><br/><br/><small>Visit #"+data.signins+"</small>");
+ if (data.tos) {
+ $('#ajaxloading').hide();
+ $('#tos').fadeIn();
+ } else {
+ thanks();
+ }
}
prepare_for_signin();
}
View
6 templates/main.html
@@ -4,8 +4,8 @@
<title>Sign in</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="/static/md5.js"></script>
- <script type="text/javascript" src="/static/signin.js?v=13"></script>
- <link rel="stylesheet" type="text/css" href="/static/signin.css?v=13" />
+ <script type="text/javascript" src="/static/signin.js?v=14"></script>
+ <link rel="stylesheet" type="text/css" href="/static/signin.css?v=14" />
</head>
<body id="body">
@@ -173,7 +173,7 @@ <h2 style="margin-top:0">Please use your @hackerdojo.com address</h2>
<input id="em" type="text" name="email" autocomplete="off" >
<a style="color:green; font-size:9px" href="#" onclick="$('#privacy').fadeIn();">E-mail Privacy</a>
<br>
- <input type="button" value="Member" onclick="clickmember()" />
+ <input type="button" value="Member" onclick="go('Member')" />
<input type="button" value="Guest" onclick="go('Guest')" />
<input type="button" value="Event Attendee" onclick="go('Event')" />
{% endif %}

0 comments on commit e655a07

Please sign in to comment.
Something went wrong with that request. Please try again.