コード例 #1
0
ファイル: app.py プロジェクト: aqueed-shaikh/submissions
def register():
    database = client.userdb
    collection = database.usercol
    if request.method == "GET":
        return render_template("register.html")
    else:
        username = request.form["username"].encode("ascii", "ignore")
        password = request.form["password"].encode("ascii", "ignore")
        if request.form["button"] == "Submit":
            if auth.exists(username):
                return render_template("success.html", username=username)
            else:
                auth.adduser(username, password)
                return render_template("login.html")
        else:
            return render_template("register.html")
コード例 #2
0
def register():
    if request.method == "GET":
        return render_template("register.html",
                               invalid="False",
                               repeat="False")
    else:
        usernameu = request.form['username']
        username = usernameu.encode('ascii', 'ignore')
        passwordu = request.form['password']
        password = passwordu.encode('ascii', 'ignore')
        passwordretypeu = request.form['passwordretype']
        passwordretype = passwordretypeu.encode('ascii', 'ignore')

        if password == passwordretype:
            if adduser(username, password):
                session['username'] = username
                return redirect(url_for('home'))
            else:
                return render_template("register.html",
                                       invalid="False",
                                       repeat="True")
        else:
            return render_template("register.html",
                                   invalid="True",
                                   repeat="False")
コード例 #3
0
def register():
    database = client.userdb
    collection = database.usercol
    if request.method=="GET":
        return render_template("register.html")
    else:
        username=request.form["username"].encode("ascii","ignore")
        password=request.form["password"].encode("ascii","ignore")
        if request.form["button"]=="Submit":
            if auth.exists(username):
                return render_template("success.html",username=username)
            else:
                auth.adduser(username,password)
                return render_template("login.html")
        else:
            return render_template("register.html")
コード例 #4
0
def Register():
    if "Username" in session:
        return redirect(url_for("Home"))
    elif request.method == "GET":
        return render_template("Register.html")
    elif request.method == "POST":
        User = request.form["Username"]
        if not auth.authenticate(User, request.form['Password']):
            auth.adduser(User, request.form["Password"])
            session["Username"] = User
        #Database = shelve.get_shelve()
        #if Username in Database:
        #     return render_template("Register.html")
        #else:
        #     Database[Username] = Password

        return redirect(url_for("Home"))
コード例 #5
0
def Register():
     if "Username" in session:
          return redirect(url_for("Home"))
     elif request.method == "GET":
          return render_template("Register.html")
     elif request.method == "POST":
          User = request.form["Username"]
          if not auth.authenticate(User, request.form['Password']):
               auth.adduser(User, request.form["Password"])
               session["Username"] = User
          #Database = shelve.get_shelve()
          #if Username in Database:
          #     return render_template("Register.html")
          #else:
          #     Database[Username] = Password
              
          return redirect(url_for("Home"))
コード例 #6
0
ファイル: sqlapp.py プロジェクト: aqueed-shaikh/submissions
def register():
    database = sqlite3.connect('names.db')
    database.execute('''
    CREATE TABLE if not exists user(username text, password text)
''')
    if request.method == "GET":
        return render_template("register.html")
    else:
        username = request.form["username"].encode("ascii", "ignore")
        password = request.form["password"].encode("ascii", "ignore")
        if request.form["button"] == "Submit":
            if auth.exists(username):
                return render_template("success.html", username=username)
            else:
                auth.adduser(username, password)
                return render_template("register.html")
        else:
            return render_template("register.html")
コード例 #7
0
def register():
    database = sqlite3.connect('names.db')
    database.execute('''
    CREATE TABLE if not exists user(username text, password text)
''')
    if request.method=="GET":
        return render_template("register.html")
    else:
        username=request.form["username"].encode("ascii","ignore")
        password=request.form["password"].encode("ascii","ignore")
        if request.form["button"]=="Submit":
            if auth.exists(username):
                return render_template("success.html",username=username)
            else:
                auth.adduser(username,password)
                return render_template("register.html")
        else:
            return render_template("register.html")
コード例 #8
0
def register():
    if request.method == 'GET':
        return render_template("register.html",error="")
    elif request.method == 'POST':
        user = request.form['user'].encode('ascii','ignore')
        pw = request.form['pass'].encode('ascii','ignore')
        if adduser(user, pw):
            return redirect(url_for('login'))
        else: 
            return render_template("register.html",error="Username already exists")
コード例 #9
0
def register():
    if request.method == 'GET':
        return render_template("register.html", error="")
    elif request.method == 'POST':
        user = request.form['user'].encode('ascii', 'ignore')
        pw = request.form['pass'].encode('ascii', 'ignore')
        if adduser(user, pw):
            return redirect(url_for('login'))
        else:
            return render_template("register.html",
                                   error="Username already exists")
コード例 #10
0
def register():
    if "username" in session:
        return redirect("home")
    elif request.method == "GET":
        return render_template("register.html", message = "")
    else: 
        user = request.form["user"].encode("utf8")
        pw = request.form["pass"].encode("utf8")
        if adduser(user, pw):
            return redirect("login")
        else:
	    return render_template("register.html", message = "Username already taken.")
コード例 #11
0
ファイル: app.py プロジェクト: aqueed-shaikh/submissions
def register():
    if "username" in session:
        return redirect("home")
    elif request.method == "GET":
        return render_template("register.html", message="")
    else:
        user = request.form["user"].encode("utf8")
        pw = request.form["pass"].encode("utf8")
        if adduser(user, pw):
            return redirect("login")
        else:
            return render_template("register.html",
                                   message="Username already taken.")
コード例 #12
0
def register():
    if 'user' in session:
        return redirect(url_for('home'))
    elif request.method == "GET":
        return render_template("register.html", message = "")
    else:
        button = request.form['button'].encode("utf8")
        if button == "Register":
            if auth.adduser(request.form['user'], request.form['pass']) == True:
                return redirect(url_for('home'))
            else:
                return render_template("register.html", message = "User exists already. Please login.")
        else:
            return redirect(url_for('login'))
コード例 #13
0
def adduser(clicks, username, email, current_state):
	#print('adduser() triggered')
	if clicks > 0:
		adduser_code = auth.adduser(username.lower(), email.lower())
		if adduser_code == 0:
			#print('adduser success')
			return '/adduser_success'
		else:
			#print('adduser failed:', adduser_code)
			if adduser_code == 1:
				return '/adduser_failure1'
			elif adduser_code == 2:
				return '/adduser_failure2'
	else:
		return current_state
コード例 #14
0
ファイル: app2.py プロジェクト: aqueed-shaikh/submissions
def register():
    if 'user' in session:
        return redirect(url_for('home'))
    elif request.method == "GET":
        return render_template("register.html", message="")
    else:
        button = request.form['button'].encode("utf8")
        if button == "Register":
            if auth.adduser(request.form['user'],
                            request.form['pass']) == True:
                return redirect(url_for('home'))
            else:
                return render_template(
                    "register.html",
                    message="User exists already. Please login.")
        else:
            return redirect(url_for('login'))
コード例 #15
0
def register():
    if request.method == "GET":
        return render_template("register.html",invalid="False",repeat="False")
    else :
        usernameu = request.form['username']
        username = usernameu.encode('ascii','ignore')
        passwordu = request.form['password']
        password = passwordu.encode('ascii','ignore')
        passwordretypeu = request.form['passwordretype']
        passwordretype = passwordretypeu.encode('ascii','ignore')

        if password == passwordretype:
            if adduser(username, password):
                session['username'] = username
                return redirect(url_for('home'))
            else:
                return render_template("register.html",invalid="False",repeat="True")
        else:
            return render_template("register.html",invalid="True",repeat="False")