def start(): if session.get('user'): return redirect(url_for('home')) else: if request.method == "POST": if request.form.get("action") == "login": return redirect(url_for('login_page')) elif request.form.get("action") == "register": return redirect(url_for('register')) else: cur = mysql.connection.cursor() pssw1 = random_password() name = "guest" username = random_username() inv_code = "NOT_REGISTERED" level = 0 password = hash_password(pssw1) session['logged_in'] = True session['admin'] = False session['user'] = username session['state'] = "clear" session['level'] = 0 session['tip_date'] = "clear" add_user(cur, name, username, password, inv_code, level) cur.close() return redirect(url_for('intro')) return render_template("start.html")
async def send_welcome(message: types.Message): user_id = message.from_user.id if in_database(user_id): if user_id in admins: await bot.send_message( message.from_user.id, f"Привет, {message.from_user.first_name}", reply_markup=markup.keyboard_categories(user_id)) else: await bot.send_message( message.from_user.id, f"Добро пожаловать, {message.from_user.first_name}!", reply_markup=markup.keyboard_categories(user_id)) else: if user_id in admins: await bot.send_message( message.from_user.id, f"Привет, {message.from_user.first_name}", reply_markup=markup.keyboard_categories(user_id)) else: link = message.get_args() if link != "": if link == database.get_invite_link(): await bot.send_message( message.from_user.id, f"Добро пожаловать, {message.from_user.first_name}!", reply_markup=markup.keyboard_categories(user_id)) database.add_user(message.from_user.id) database.delete_invite_link() else: await bot.send_message(message.from_user.id, f"У вас нет доступа к боту!") else: await bot.send_message(message.from_user.id, f"У вас нет доступа к боту!")
def prompt_add_user(): """ Add new user. :return: """ username = input('Enter username: ') database.add_user(username)
def signin_User(): form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user is not None: # next = request.args.get('next') # return redirect(next or url_for('welcome')) return render_template('./login/signup.html', form=form, message="该邮箱已被注册") else: # login_user(user) # 使用sha512进行hash hash = hashlib.sha512() # 将盐值和密码进行拼接 hashpassword = form.salt.encode() + form.password.data.encode() hash.update(hashpassword) form.password.data = hash.hexdigest() try: id = (User.query.order_by((User.id).desc()).first()).id + 1 except AttributeError: id = 0 add_user(form, id) next = request.args.get('next') return redirect(next or url_for('upload_file')) # return render_template('welcome.html', form=form, userName=form.userName.data) else: return render_template('./login/signup.html', form=form, message=list(form.errors.values())[0][0])
def wrapper(*args, **kwargs): user_info = database.check_user(kwargs['event'].data["from"]["userId"]) if user_info["not_exist"]: database.add_user(kwargs['event'].data["from"]["userId"]) user_info = database.check_user( kwargs['event'].data["from"]["userId"]) func(*args, **kwargs)
def add_user(msg): usr_lang = msg.text db.add_user(msg.chat.id, usr_lang) hide_markup = types.ReplyKeyboardRemove() bot.send_message(message.chat.id, 'Perfect!', reply_markup=hide_markup)
def add_user(): username = tbox1Text.get() password = tbox2Text.get() passwordreenter = tbox3Text.get() if (password == passwordreenter): print(username + " " + password) db.add_user(username, password)
def FUN_add_user(): if session.get("current_user", None) == "ADMIN": # only Admin should be able to add user. # before we add the user, we need to ensure this is doesn't exsit in database. We also need to ensure the id # is valid. if request.form.get('id').upper() in database.list_users(): user_list = database.list_users() user_table = zip(range(1, len(user_list) + 1), user_list, [ x + y for x, y in zip(["/delete_user/"] * len(user_list), user_list) ]) return render_template("admin.html", id_to_add_is_duplicated=True, users=user_table) if " " in request.form.get('id') or "'" in request.form.get('id'): user_list = database.list_users() user_table = zip(range(1, len(user_list) + 1), user_list, [ x + y for x, y in zip(["/delete_user/"] * len(user_list), user_list) ]) return render_template("admin.html", id_to_add_is_invalid=True, users=user_table) else: database.add_user(request.form.get('id'), request.form.get('pw')) return redirect(url_for("FUN_admin")) else: return abort(401)
def add_reaction_callback(query, data, chat, message): db.add_user(query.sender.id) post = db.get_post(message.id, chat.id) sender = query.sender reaction = db.get_reaction(post.post_id, sender.id) btns = botogram.Buttons() # se viene cliccata la stessa reazione la toglie, altrimenti la cambia if reaction: if reaction.reaction_type == 'upvote': if data == 'upvote': db.remove_reaction(post.post_id, sender.id) elif data == 'downvote': db.set_reaction(post.post_id, sender.id, 'downvote') elif reaction.reaction_type == 'downvote': if data == 'downvote': db.remove_reaction(post.post_id, sender.id) elif data == 'upvote': db.set_reaction(post.post_id, sender.id, 'upvote') # aggiunge una nuova reazione else: db.add_reaction(post.post_id, sender.id, data) # aggiorna i numeri nei bottoni post_reactions = db.get_reactions_count(post.post_id) btns[0].callback(f"👍{post_reactions['upvotes']}", "add_reaction_callback", "upvote") btns[0].callback(f"👎{post_reactions['downvotes']}", "add_reaction_callback", "downvote") message.edit_attach(btns)
def register(): if logged_in(): return redirect(url_for('home')) error = None if request.method == 'POST': email = request.form['email'] username = request.form['username'] password1 = request.form['password1'] password2 = request.form['password2'] if database.get_user(username): error = 'Username already taken.' elif password1 != password2: error = 'Passwords do not match.' else: database.add_user( email, username, bcrypt.hashpw(password1.encode('utf-8'), bcrypt.gensalt()), get_time(time.time())) if not os.path.isdir(app.config['upload_folder'] + username + '/'): os.mkdir(app.config['upload_folder'] + username + '/') session['username'] = username app.logger.info(username + ' account created') return redirect(url_for('home')) return render_template('register.html', pagetitle='Register', error=error)
def register_page(): # if user is logged in, don't let them see the page at all if g.user: return show_message('You already have an account here, moron') if request.method == 'POST': if not request.form['username']: return render_template('register.html', error="Username is required") elif not request.form['email'] or '@' not in request.form['email']: return render_template('register.html', error="Please enter a valid email") elif not request.form['password']: return render_template('register.html', error="Please enter a password") elif request.form['password'] != request.form['password2']: return render_template( 'register.html', error=" Please make sure your passwords match") # TODO: check for username being identical here db = database.get_db() database.add_user(request.form['username'], request.form['email'], generate_password_hash(request.form['password']), request.form['timezone']) return redirect(url_for('login_page')) return render_template('register.html')
def signup(): if request.method=="GET": return render_template("signup.html") else: session["uname"] = request.form["user"] database.add_user(request.form["user"], request.form["pass"]) return redirect(url_for("login"))
def FUN_add_user(): if session.get("current_user", None) == "ADMIN": # only Admin should be able to add user. # before we add the user, we need to ensure this is doesn't exsit in database. We also need to ensure the id is valid. if request.form.get('id').upper() in list_users(): user_list = list_users() all_fields = user_db_all_fields() user_table = zip(range(1, len(user_list)+1),\ user_list,\ [x + y for x,y in zip(["/delete_user/"] * len(user_list), user_list)], all_fields[2]) return (render_template("admin.html", id_to_add_is_duplicated=True, users=user_table)) if " " in request.form.get('id') or "'" in request.form.get( 'id') or not request.form.get( 'id' ): # 3rd condition I have added..for not adding empty string user_list = list_users() all_fields = user_db_all_fields() user_table = zip(range(1, len(user_list)+1),\ user_list,\ [x + y for x,y in zip(["/delete_user/"] * len(user_list), user_list)], all_fields[2]) return (render_template("admin.html", id_to_add_is_invalid=True, users=user_table)) else: add_user(request.form.get('id'), request.form.get('pw')) return (redirect(url_for("FUN_admin"))) else: return abort(401)
def register(): """ Api.register method arguments: [username, password] returns: empty body 201 -- registration success 400 -- wrong arguments 409 -- username exists 500 -- internal error """ if not request.json \ or not 'username' in request.json or len(request.json['username']) == 0 \ or not 'password' in request.json or len(request.json['password']) == 0: abort(400) conn = conn_get() user = database.get_user(conn, request.json['username']) if user is not None: abort(409) user = { 'username': request.json['username'], 'password': generate_password_hash(request.json['password']), } database.add_user(conn, user) conn.commit() return "", 201
def sign_up(): if request.method == 'POST': username = request.form['username'] password = request.form['password'] database.add_user(username, password) return render_template("login.html") else: return render_template("sign_up.html")
def add_user(): username = tbox1Text.get() password = tbox2Text.get() passwordreenter = tbox3Text.get() if (password == passwordreenter): print(username + " " + password) db.add_user(username, bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode("utf-8"))
def index(): name = 'Noname' if request.method == 'POST': name = request.form['name'] add_user(name) _data = read_from_db() return render_template('index.html', data=_data)
def register(): if (request.method == 'POST'): email = request.form['email'] password = request.form['password'] db.add_user(email, password) print(email, password) return "Hello" return render_template('register.html')
def test_users(self, mocked_db): with tempfile.NamedTemporaryFile() as tempFile: mocked_db = tempFile.name database.add_user('an12') result = check_database_entry(mocked_db, "username", "users") print(result) self.assertEqual()
def main(): passwd = password if (password_check(passwd)): database.add_user(username, password) print('Account created') else: print("Invalid Password !!")
def sign_up(): if request.method == 'POST': name = request.form['name'] email = request.form['email_address'] passcode = request.form['passcode'] database.add_user(name, email_address, passcode) return render_templete("login.html") else: return render_templete("sign_up.html")
def wrapper(*args, **kwargs): user_info = database.check_user(kwargs['event'].data["from"]["userId"]) if user_info["not_exist"]: database.add_user(kwargs['event'].data["from"]["userId"], kwargs['event'].data["from"]["firstName"], kwargs['event'].data["from"].get('lastName', '')) user_info = database.check_user( kwargs['event'].data["from"]["userId"]) func(*args, **kwargs)
def edit_schedule(): if not google.authorized: return redirect(url_for("home")) user_info = google.get("/oauth2/v1/userinfo").json() user = database.get_user(user_info["id"]) flash( "If you have an advanced science lab during Study Hall, enter Study Hall.", "warning") try: if int(user_info['email'][:2]) + 2000 > int(datetime.now().year) + 4: flash( "Middle school students are restricted to the manual entry option. Fill in your schedule with all periods (offteam and team) with the exception of Flex and lunch.", "warning") except: pass if user == None: hits = 0 else: last = int(user['_id'].generation_time.timestamp()) now = int(time.time()) if now - last > int(RATE_TIME): hits = 0 else: hits = user['hits'] if request.method == "POST": if hits < int(RATE_NUM): schedule = {} for i in range(8): schedule[str(i)] = { "teacher_name": f"{request.form.get('t' + str(i))}" } if user == None: PARAMS = { 'username': "******", "avatar_url": "https://classreveal.com/static/img/favicon.png", "content": user_info['name'] + " (" + str(13 - (int(user_info['email'][:2]) - int(datetime.now().year - 2000))) + "th grade) joined Class Reveal @ " + str(datetime.now()) } requests.post(url=WEBHOOK, data=PARAMS) database.add_user(user_info["id"], user_info["name"], hits + 1, schedule) else: flash("Your account has been rate limited.", "danger") return redirect(url_for("home")) user = database.get_user(user_info["id"]) schedule = user["schedule"] if user else "" return render_template("edit.html", schedule=schedule, user_id=True)
def start(update, context): uid = update.effective_message.chat.id if not db.banned(uid): msg = "I'm glad to see you again, Traveler!" if not db.cached(uid): _state(uid) db.add_user(uid) msg = f"Hi Traveler, I'm Paimon!\n\n{HELP}" ut.send(update, msg)
def signup(): if request.method == "GET": return render_template('signup.html') elif request.method =="POST": name = request.form['name'] username = request.form['Username'] password = request.form['Password'] database.add_user(name, username , password) return render_template('signin1.html')
def add_user(): user = { "email": request.form["email"], "username": request.form["username"], "password_hash": generate_password_hash(request.form["password"]), "permissions": request.form["permissions"] } database.add_user(user) return redirect(url_for("admin_users"))
def add_user(channel, name): # Check if username has leading symbols (@, +, etc) and remove them if not name[0].isalnum(): name = name[1:] if channel in users: users[channel].add(name) else: users[channel] = set([name]) database.add_user(name)
def sign_up(): import pmv username = request.form['username'].lower() password = request.form['password'] remember = request.form.get('remember') is not None db.add_user(username, generate_password_hash(password)) # TODO Add some proper validation, redirecting for signup # if len(data) == 0: user = pmv.get_user(username) login_user(user, remember) return redirect(url_for('main.index'))
def register_user(): user_name = input("Enter your name: ") user_surname = input("Enter your surname: ") user_email = input("Enter your email '*****@*****.**': ") user_telephone = check_if_correct_number("phone number", 9) user_PESEL = check_if_correct_number("PESEL", 11) user_login = input("Enter your user name: ") user_password = input("Enter your password: ") user_type = 0 database.add_user(user_name, user_surname, user_email, user_telephone, user_PESEL, user_login, user_password, user_type)
def populate_user_table(self, cursor, number_of_users=10_000): '''Populates the user table in main.db (needs to already exist) with the amount of users specified in the input arg. Expects a DataBaseConnection object to be passed in as first arg ''' first_names = data.fetch_first_names() last_names = data.fetch_last_names() for _ in range(number_of_users): user_data = self._generate_random_user_data( first_names, last_names) database.add_user(cursor, user_data)
def register(): if current_user.is_authenticated: return redirect(url_for('file_routes.home')) if request.method == 'POST': username = request.form['username'] password = request.form['password'] email = request.form['email'] database.add_user(username, email, bcrypt.generate_password_hash(password, rounds=12)) return redirect(url_for('authentication.login')) return render_template('register.html')
def register(): nick_name = input("Enter your nickname: ") password = input("Enter your passowrd: ") email = input("Enter your email([email protected]): ") join_date = input("Enter current date(YYYY-MM-DD): ") first_name = input("Enter your firstname: ") last_name = input("Enter your last name: ") phone_number = input("Enter your phone number(123123123): ") birth_date = input("Enter your birth date(YYYY-MM-DD): ") country = input("Enter your country(PL,DE,CZ,TH,US,CA,AU,GB): ") gender = input("Enter your gender(Male,Female,Other): ") database.add_user(nick_name, password, email, join_date, first_name, last_name, phone_number, birth_date, country, gender)
def add_user(username): # escape username username = escape(username) result = database.add_user(username) if result == []: return "[]" return dumps((result.name, str(result.id), result.score))
def procces_data(user_id, user_name, friends, followers): user_name = user_name.lower() # Check if user exists if len(database.get_user_from_screen_name(user_name)) == 0: database.add_user(user_id, user_name, True) database.make_new_friend_table(user_name) database.make_new_follower_table(user_name) for f in friends: database.add_friend(user_name, f["id"], f["screen_name"]) for f in followers: database.add_follower(user_name, f["id"], f["screen_name"]) print "[+] %s Data Has Been Added" % user_name else: print "[*] User Already Exists Ignoring"
def register(): error = None if request.method == 'GET': return render_template('register.html', error=error) if request.method == 'POST': if len(request.form['id']) == 0: error = "GT ID cannot be empty" return render_template('register.html', error=error) if len(request.form['major']) == 0: error = "Major cannot be empty" return render_template('register.html', error=error) if len(request.form['password']) == 0: error = "Password cannot be empty" return render_template('register.html', error=error) if len(request.form['name']) == 0: error = "Name cannot be empty" return render_template('register.html', error=error) if len(request.form['email']) == 0: error = "Email cannot be empty" return render_template('register.html', error=error) if len(request.form['number']) == 0: error = "Phone number cannot be empty" return render_template('register.html', error=error) id = request.form['id'] password = request.form['password'] grade = request.form['grade'] major = request.form['major'] gender = request.form['gender'] name = request.form['name'] number = request.form['number'] email = request.form['email'] # populate user info into user table add_user(db_handler, id, name, password, gender == "male", major, \ grade == "undergraduate", number, email) print "current user table: " for row in db_handler.get_all_records(db_handler.user_tb): print row session['username'] = id session['logged_in'] = True return redirect(url_for('show_entries'))
def f_sign_up(): if request.method == 'POST': user = request.form['username'] passw = request.form['password'] repassw = request.form['re_password'] email = request.form['email'] if passw == repassw: if add_user(user, passw, email): session['user'] = user return render_template("ad-search.html", Username=user) return render_template("main.html", items=get_4())
def register_page(): # if user is logged in, don't let them see the page at all if g.user: return show_message('You already have an account here, moron') if request.method == 'POST': if not request.form['username']: return render_template('register.html', error="Username is required") elif not request.form['email'] or '@' not in request.form['email']: return render_template('register.html', error="Please enter a valid email") elif not request.form['password']: return render_template('register.html', error="Please enter a password") elif request.form['password'] != request.form['password2']: return render_template('register.html', error=" Please make sure your passwords match") # TODO: check for username being identical here db=database.get_db() database.add_user(request.form['username'], request.form['email'], generate_password_hash(request.form['password']), request.form['timezone']) return redirect(url_for('login_page')) return render_template('register.html')
def register(): """ Rekisteröi uuden käyttäjän. TODO """ username = request.form["username"] key = request.form["key"] # Validoidaan syötteet: if not username: return json("fail", {"username": "******"}) if not key or not (7 < len(key) < 500): return json("fail", {"key": "invalid key"}) existing_user = db.get_user(username) if existing_user: return json("fail", {"username": "******"}) uid = db.add_user(username, key) return json("success", {"id": str(uid)})
import sqlite3 if __name__ == "__main__": f = open('email_config.cfg', 'r') username = f.readline().strip() password = f.readline().strip() dbase = f.readline().strip() f.close() database.init_table(dbase); while(1): num, sender, body = email_util.receive_email_subj("add", username, password) if (num != -1): print "Received new user email requesting add!" sender = sender[sender.index("<") + 1:-1] body = body.split(); if not body: database.add_user(sender, sender, dbase) else: database.add_user(body[0], sender, dbase) email_util.delete_email(num, username, password) num, sender, body = email_util.receive_email_subj("quit", username, password) if (num != -1): print "Received new user email requesting removal!" sender = sender[sender.index("<") + 1:-1] body = body.split(); database.remove_user(sender, dbase) email_util.delete_email(num, username, password)
import time import datetime import math import sqlite3 import config import database import message_queue from utils import entropy TRANSFER_FEE_RATE = 0.01 database.add_user(config.nickname) bux_log = open("bux.log", "w") # Amount of repeating figures starting from the least significant one def repeating_digits(number): head, last_tail = divmod(number, 10) repeating_digits = 0 while head > 0: head, tail = divmod(head, 10) if tail == last_tail: repeating_digits += 1 else: break return repeating_digits # Money is awarded to sender every time their message epoch has repeating digits def make_money(sender, full_text):