Matthew Turk  committed 1c9ccc2

Adding a bunch of minor fixes, and registration options.

  • Participants
  • Parent commits 263c6b8

Comments (0)

Files changed (4)

File ythub/

 app = Flask(__name__)
 app.secret_key = secret_key
-app.config['MAX_CONTENT_LENGTH'] = 1024*1024*1024
+app.config['MAX_CONTENT_LENGTH'] = 1024*1024*1024*16
 gravatar = Gravatar(app,

File ythub/

 yt data hub
+welcome_notice = r"""
+Hi %(name)s,
+Welcome to the yt Hub.  Your username is %(username)s , and you can log in at
+ to get your API key.
+Be sure to check out the Getting Started section for how to upload images, data
+and maps.
+yt data hub

File ythub/templates/login.html

       <div class="row">
         <div class="span12">
-          <form action="login" method=post class="form-horizontal">
+          <form action="login" method="post" class="form-horizontal">
             <legend>Login Information</legend>
             <div class="control-group">
               <label class="control-label" for="name">Username</label>
                 <input type="password" class="input-xlarge" name="password" id="password">
+            <input type=hidden name=next value="{{ next }}">
             <button type="submit" class="btn btn-primary">Login</button>
-            <input type=hidden name=next value="{{ next }}">
       <div class="row">
         <div class="span12">
-          <form action="reset_pw" method=post class="form-horizontal">
+          <form action="reset_pw" method="post" class="form-horizontal">
             <legend>Password Reset</legend>
             <div class="control-group">
               <label class="control-label" for="email">E-mail address</label>

File ythub/

     MinimalStaticOutput, MinimalProjectionData
 from ythub.authentication import require_api_key
 from math import ceil
-from ythub.send_email import pw_recovery_template, new_user_notice
+from ythub.send_email import pw_recovery_template, new_user_notice, \
+                             welcome_notice
 from ythub.database import db_session, ses_conn
 from ythub.local_config import admin_emails
 def create_user():
     error = None
     if request.method == 'POST':
+        if request.form.get("zap", "") != "rowsdower":
+            mylog.warning("False attempt with a manual post.")
+            flash("Nice try.")
+            return redirect("/")
         if request.form.get('password2') != request.form.get('password'):
+            mylog.warning("Bad password matching")
             flash("Passwords don't match.")
             return render_template("create_user.html")
         user = register_user(request.form.get('name'),
                              request.form.get('url', ""))
         if user:
+            print "Created new user: %s" % user.username
+            email_subject = "Welcome to the yt Data Hub!"
+            email_body = welcome_notice % {'username':user.username,
+                                           'name'}
+            ses_conn.send_email(
+                "", email_subject, email_body,
             email_subject = "New yt Data Hub User"
             email_body = new_user_notice % {'username':user.username,
             flash('Registration successful.')
             return redirect('/')
+            mylog.warning("Failed to register user: %s",
+                          request.form.get("username"))
             flash('Failed to register user. Try another username.')
+            return make_response("Could not create user.", 400)
+    flash('Registrations are currently disabled.')
+    return redirect('/')
     return render_template("create_user.html")
 @app.route('/login', methods=['GET', 'POST'])
             flash('Invalid login.')
     return render_template('login.html', error=error)
-@app.route('/reset_pw/', methods=['POST'])
+@app.route('/reset_pw', methods=['POST'])
 def pw_recovery():
     email = request.form.get('email')
     user = User.query.filter( == email).first()