Ejemplo n.º 1
0
def login():
   error = None
   if request.method == 'POST':    #button pressed?
       nam=request.form['username']
       pw=request.form['password']
       #check if username is in our database
       if runSelectws(['user.uid'],'user.uid="%s"'%nam.lower()) == []:#run a search here to see if it's in the users.uid table
           error = 'Invalid username'
       elif runSelectws(['user.uid'],'user.uid="%s" and user.pw="%s"'%(nam.lower(),pw)) ==[]:#run a search here to see if it's in teh users.pw table
           error = 'Invalid password'
       else:
           session['logged_in'] = True
           flash('Welcome %s'%nam)
           #return redirect(url_for('welcome_screen'))
           return render_template('welcome_screen.html',error=error)
   return render_template('login.html', error=error)
Ejemplo n.º 2
0
def uidCheck(nameIn):
    # takes 'nameIn', verifies that is at least 10 characters long
    # contains no characters () and isn't already in use (all lower case)
    # returns a descriptive error or null
    goodString = string.ascii_letters + "[email protected]_+"
    res = stringCheck(nameIn, goodString)
    if res != []:
        return """The following characters are not allowed: %s""" % res
    elif len(nameIn) < 3:
        return "At least 3 characters"
    elif runSelectws(["user.uid"], 'user.uid="%s"' % nameIn) != []:
        return "Username already in use"
    else:
        return ""