def post(self): if not request.is_json: return jsonify({"msg": "Missing JSON in request"}), 400 data = request.get_json() username = data['username'] password = data['password'] if check_username_exist(username): return jsonify({"msg": "Username exists, please choose a new username"}), 400 register(username,password) json_response = { "status": 200, "msg": f"Thank you for registering {username}" } return jsonify(json_response)
def register_subject(id, nome, status, plano_ensino, carga_horaria, id_coordenador=None): sql = """ INSERT INTO subject(id_subject, nome, status, plano_ensino, carga_horaria, id_coordenador) VALUES (?, ?, ?, ?, ?, ?) """ database.register( sql, (id, nome, status, plano_ensino, carga_horaria, id_coordenador))
def page(): if "login" in session: return redirect("/") if request.method == "POST": username = request.form['username'] password = protect(request.form['password']) confirm = protect(request.form['cpassword']) email = request.form['email'] dob = request.form['dob'] referral = request.form['referral'] if password != confirm: flash("Passwords did not match.") return redirect("/register/") else: message = database.register(username, password, email, dob, referral) if not message['success']: flash(message['message']) return redirect("/register/") else: session['login'] = username return redirect("/") return render_template("register.html")
def register(): if request.method == 'POST': username = request.form.get("username", default=None) password = request.form.get("password", default=None) if (not username or not password or username == "" or password == ""): req = {"code": "0001", "result": "用户名或密码格式错误", "data": {}} return jsonify(req) print(request.form) status, msg = database.register(collection_name, { "username": username, "password": password }) if status == True: req = { "code": "0000", "result": "注册成功", "data": { "username": username, "token": str(msg) } } return jsonify(req) else: req = {"code": "0001", "result": msg, "data": {}} return jsonify(req)
def Signup(): try: if request.method == 'POSt': return register(request.args.get('Dealer')) return "Invalid Request" except Exception as e: print str(e) return 'Unable to Register'
def register(msg): chatid = msg.chat.id userid = msg.from_user.id if database.register(chatid, userid): bot.send_message(chat_id=msg.chat.id, text='Usuário cadastrado com sucesso!') else: bot.send_message(chat_id=msg.chat.id, text='Usuário já está cadastrado.')
def signup(): if request.method == 'GET': return render_template('signup.html') else: success = register(request.form['username'],request.form['password'],request.form['firstName'],request.form['lastName']) if success is True: return "Signup successful!" else: return "Signup failed: Email already exists!"
def register(): username = input("Username: "******"Password: "******"Address(Don't worry, you could change it later):") is_registered = database.register(username, password, address) if is_registered: print("Registration Successful") else: print("That username has already been taken")
def signup_page(): form = RegisterForm(request.form) if form.validate_on_submit(): print("in") sql = "SELECT * FROM user WHERE username = %s" mycursor.execute(sql, (form.username.data, )) same_username = mycursor.fetchall() if len(same_username) > 0: return render_template("register.html", form=form) hashed = hasher.hash(form.password.data) register(form, hashed, mycursor, mydb) add_days_to_user(mycursor, mydb) return redirect(url_for('profile_page', username=session['user_id'])) else: return render_template("register.html", form=form)
def register(): bpy.utils.register_class(ModifierNodesPrefs) typedesc.register() group.register() object_nodes.register() mod_node.register() driver.register() blang_path = os.path.join(directory, "modifiers") generator.load_all_modifiers(blang_path) # explicit node types to register nodes.register() mod_node.mod_node_item.register() database.register() prefs = bpy.context.user_preferences.addons[__name__].preferences
def register(): bpy.utils.register_class(ModifierNodesPrefs) typedesc.register() group.register() object_nodes.register() mod_node.register() driver.register() blang_path = os.path.join(directory, 'modifiers') generator.load_all_modifiers(blang_path) # explicit node types to register nodes.register() mod_node.mod_node_item.register() database.register() prefs = bpy.context.user_preferences.addons[__name__].preferences
def register(): details = request.form.to_dict() # print(details) user = details['username'] password = details['password'] status = 'exisiting account' if (db.register(user, password)): status = 'account created' print(status) return jsonify({'status': status})
def signup(): username = get_username() if username: return redirect(url_for("index")) if request.method == "GET": return render_template("signup.html") else: username = request.form["username"] password = request.form["password"] pnumber = request.form["pnumber"] email = request.form["email"] password = hash(password) if db.register(username, pnumber, email, password): return redirect(url_for("login")) return render_template("signup.html", error="Username taken!")
def register(): if "submit" in request.form: username = request.form['l_id'] password = request.form['pwd'] dob=request.form['dob'] fname=request.form['f_name'] lname=request.form['l_name'] gender=request.form['gender'] if(db.register(fname,lname,dob,gender,username,password)): return redirect(url_for('product')) else: return render_template('feature') # q = "insert into login(username,password,type)values('%s','%s','%s')"% (username,password,"user") return render_template('user2.html')
def register(): if request.method == "POST" and request.form["username"] and request.form["password"]: database.register(request.form["username"], request.form["password"]) return redirect(url_for("login")) return render_template("register.html")
def setUp(self): database.create_users_table() database.create_restaurant_table() database.create_orders_table() database.create_taxes_table() database.register('Barney', '420', "Mclarens")
def register_student(id, nome): sql = "INSERT INTO student(id_student, nome) VALUES (?, ?)" return database.register(sql, (id, nome))
def register(): if request.method == "POST" and request.form["username"] and request.form[ "password"]: database.register(request.form["username"], request.form["password"]) return redirect(url_for("login")) return render_template("register.html")
def Entrance(_surface): # 得到存档。修改后的初始存档或读取的存档 # 存档包括:warrior, floors, now_floor, POLICE_PROB show_entrance(_surface) while True: for event in pygame.event.get(): if event.type == QUIT: doc = saving.document(newbie, _now_floor, floors, POLICE_PROB, police_defeated) doc.save(_id) exit() elif event.type == MOUSEMOTION: p = check_mouse(pygame.mouse.get_pos()) if p != -1: pygame.draw.rect(_surface, Color('white'), (312, 174 + 92 * p, 176, 32), 2) else: for i in range(0, 3): pygame.draw.rect(_surface, Color('black'), (312, 174 + 92 * i, 176, 32), 2) pygame.display.update() elif event.type == MOUSEBUTTONDOWN: p = check_mouse(pygame.mouse.get_pos()) if p == 0: # 注册账号 empty(_surface, (0, 170, 800, 280)) name_txt = text("猛士,尊姓大名?按回车确认", 192, 202, font_32, Color('gold')) name_txt.show(_surface) username = inputbox.ask(_surface, (192, 326, 416, 32), False) while username == '': empty(_surface, (0, 170, 800, 280)) hint_txt = text("猛士当青史留名,不可做无名英雄也。", 128, 202, font_32, Color('gold')) hint_txt.show(_surface) username = inputbox.ask(_surface, (192, 326, 416, 32), False) while username == 'origin' or username == 'Logic': empty(_surface, (0, 170, 800, 280)) hint_txt = text("此名不可用。", 304, 202, font_32, Color('gold')) hint_txt.show(_surface) username = inputbox.ask(_surface, (192, 326, 416, 32), False) while database.get_user(username) is not None: empty(_surface, (0, 170, 800, 280)) hint_txt = text("猛士岂可寄他人名下?此名已存在,请重新输入", 64, 202, font_32, Color('gold')) hint_txt.show(_surface) username = inputbox.ask(_surface, (192, 326, 416, 32), False) empty(_surface, (0, 170, 800, 280)) pswd_txt = text("您的神圣存档不容他人侵犯。请设定密码", 112, 202, font_32, Color('gold')) pswd_txt.show(_surface) password = inputbox.ask(_surface, (192, 326, 416, 32), True) while password == '': empty(_surface, (0, 170, 800, 280)) hint_txt = text("总有一些地方是不能随便给别人看的。", 128, 202, font_32, Color('gold')) hint_txt.show(_surface) password = inputbox.ask(_surface, (192, 326, 416, 32), True) empty(_surface, (0, 170, 800, 280)) pswd_confirm_txt = text("请再次输入以确认密码", 240, 202, font_32, Color('gold')) pswd_confirm_txt.show(_surface) password_confirm = inputbox.ask(_surface, (192, 326, 416, 32), True) while password_confirm != password: empty(_surface, (0, 170, 800, 280)) hint_txt = text("如此大意可是要被小怪兽吃掉的哦。重新确认密码", 48, 202, font_32, Color('gold')) hint_txt.show(_surface) password_confirm = inputbox.ask(_surface, (192, 326, 416, 32), True) database.register(username, password) load_game(_surface, username, True) elif p == 1: # 登录账号 empty(_surface, (0, 170, 800, 280)) name_txt = text("猛士,告诉我您的大名,按回车确认", 144, 202, font_32, Color('gold')) name_txt.show(_surface) username = inputbox.ask(_surface, (192, 326, 416, 32), False) user = database.get_user(username) while user is None: empty(_surface, (0, 170, 800, 280)) hint_txt = text("查无此人,请重新输入", 240, 202, font_32, Color('gold')) hint_txt.show(_surface) username = inputbox.ask(_surface, (192, 326, 416, 32), False) user = database.get_user(username) empty(_surface, (0, 170, 800, 280)) pswd_txt = text("密码是?", 336, 202, font_32, Color('gold')) pswd_txt.show(_surface) password = inputbox.ask(_surface, (192, 326, 416, 32), True) while password != user[1]: empty(_surface, (0, 170, 800, 280)) hint_txt = text("密码错误,请重新输入", 240, 202, font_32, Color('gold')) hint_txt.show(_surface) password = inputbox.ask(_surface, (192, 326, 416, 32), True) empty(_surface, (0, 170, 800, 280)) if user[4] != 0: resume_txt = text("继续上次游戏", 304, 202, font_32, Color('blue')) resume_txt.show(_surface) else: resume_txt = text("您的复活次数已用完。", 240, 202, font_32, Color('white')) resume_txt.show(_surface) restart_txt = text("从头来过", 336, 326, font_32, Color('blue')) restart_txt.show(_surface) pygame.display.update() doc = None while True: for event in pygame.event.get(): if event.type == QUIT: exit() elif event.type == MOUSEMOTION: mouse_pos = pygame.mouse.get_pos() if Rect(304, 202, 192, 32).collidepoint(mouse_pos) and user[4] != 0: pygame.draw.rect(_surface, Color('white'), (304, 202, 192, 32), 2) elif Rect(336, 326, 128, 32).collidepoint(mouse_pos): pygame.draw.rect(_surface, Color('white'), (336, 326, 128, 32), 2) else: pygame.draw.rect(_surface, Color('black'), (304, 202, 192, 32), 2) pygame.draw.rect(_surface, Color('black'), (336, 326, 128, 32), 2) elif event.type == MOUSEBUTTONDOWN: mouse_pos = pygame.mouse.get_pos() if Rect(304, 202, 192, 32).collidepoint(mouse_pos) and user[4] != 0: load_game(_surface, username, False) elif Rect(336, 326, 128, 32).collidepoint(mouse_pos): database.reset_life(username) database.commit() load_game(_surface, username, True) pygame.display.update() elif p == 2: exit()
def register(id, name): conn = sqlite3.connect(db) if (conn is not None): return database.register(conn, id, name) conn.close()
database.recreateData() userid = input('Please enter your Userid: ') print( "Remember NOT to give anybody your password. Even the admin, which is myself, will not ask you for your password." ) #need userid to identify the user. Userid should be automatically identified by the system, not through user input. User is required to be already logged in online before accessing this service. As such, passwords are not required (but can be implemented). with open('userdb.txt') as json_file: UserDB = json.load(json_file) while not (userid in UserDB.keys()): choice = input( "Invalid account! Looks like you have not registered for this service yet. Are you a new user? (Y/N)" ) if (choice == 'y' or choice == 'Y'): userid = database.register( UserDB) #***Pls use john5678 as new userid #getData(userid, userid+'_transactionData') --> to be implemented as a function that gets data directly from transaction db and output into userid_transactionData.csv file. else: userid = input("Please reenter userid:") print("Welcome ", UserDB[userid]['Name'], "!") savingsForecast = loadUser(UserDB, userid) # do some stuff print("How may I help you today?") initial_savings_graph = 0 #aara output #download_thread = threading.Thread(target=database.dataPrep()) #download_thread.start() # continue doing stuff
def register_teacher(id, nome): sql = "INSERT INTO teacher(id_teacher, nome) VALUES (?, ?)" database.register(sql, (id, nome))
from database.register import * import sqlite3 connection = sqlite3.connect('database/datas/login.db') c = connection.cursor() db = register() class visualizarPerfil(): """ Exibe o de perfil """ def visualizeUser(self, email): sql = "SELECT * FROM usuario WHERE email = ?" for row in c.execute(sql, (email, )): if (row[2] == email): print( "--------------------Veja seu perfil--------------------") print("\nNome completo: " + row[1]) print("E-mail: " + row[2])