def register(): if request.method == 'GET': return render_template('register.html') button = request.form['button'] username = request.form['username'] password = request.form['password'] first = request.form['first'] last = request.form['last'] if button == 'cancel': return redirect('/') else: if not password or not first or not last: return render_template('register.html', error='incomplete') criteria = {'username': username} if db.find_user(criteria): return render_template('register.html', error='username taken') else: initial_Schedule = [ "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "", "", "", "", "", "", "", "", "", "" ] user_params = { 'username': username, 'password': password, 'first': first, 'last': last, 'schedule': initial_Schedule, 'essays': [], 'Message': [] } db.new_user(user_params) session['username'] = username return redirect('/')
def home_newuser(): """The new user menu""" ui.newy1() newfname = raw_input("NEW USER FIRST NAME: ") if newfname == ":EXIT": home() else: pass newlname = raw_input("NEW USER LAST NAME: ") today = raw_input("MARK PRESENT FOR TODAY [Y/N] ") if today in ("Y", "y"): z = db.new_user(newfname, newlname, True) if z is True: print "USER ADDED... PRESS [ENTER] TO GOTO HOMESCREEN" elif z is False: print "USER WAS NOT ADDED... PRESS [ENTER] TO GOTO HOMESCREEN" raw_input() elif today == ":EXIT": home() else: z = db.new_user(newfname, newlname, False) if z is True: print "USER ADDED... PRESS [ENTER] TO GOTO HOMESCREEN" elif z is False: print "USER WAS NOT ADDED... PRESS [ENTER] TO GOTO HOMESCREEN" raw_input() home()
def registration(): post_data = request.get_json() if not post_data: return jsonify({ "result" : "error", "comment" : "Invalid format, check your input and try again" }) if not 'user_name' in post_data or not 'password': return jsonify({""" "result" : "error", "comment" : "Please follow the current template {"user_name" : "John", "password" : "*****"}" """ }) if not db.get_user_id_by_name(post_data['user_name']): db.new_user(post_data['user_name'], post_data['password']) return jsonify({ "result" : "ok", "comment": "You are successfully registered" }) else: return jsonify( { "result" : "error", "comment" : "This user_name already exists, please choose the new one" })
def register(): if request.method == "GET": return flask.render_template("register.html") email = request.form["email"] password = request.form["password"] confirmation = request.form["confirmation_password"] league_password = request.form["league_password"] if password != confirmation: return flask.render_template("register.html", error_msg="Your password did not match the confirmation") if league_password != settings.league_password: return flask.render_template("register.html", error_msg="Bad league password") session["email"] = email db.new_user(email, sha.sha(password).hexdigest(), email) if db.num_users() == 1: return redirect( "https://fiesta.cc/authorize?state=create_group&response_type=code&client_id=%s&_register_email=%s" % (settings.client_id, email) ) else: fiesta.add_member(email) return redirect("/homepage")
def home_newuser(): """The new user menu""" ui.newy1() newfname = raw_input("NEW USER FIRST NAME: ") if newfname == ":EXIT": home() else: pass newlname = raw_input("NEW USER LAST NAME: ") today = raw_input("MARK PRESENT FOR TODAY [Y/N] ") if today in ("Y","y"): z = db.new_user(newfname,newlname,True) if z is True: print "USER ADDED... PRESS [ENTER] TO GOTO HOMESCREEN" elif z is False: print "USER WAS NOT ADDED... PRESS [ENTER] TO GOTO HOMESCREEN" raw_input() elif today == ":EXIT": home() else: z = db.new_user(newfname,newlname,False) if z is True: print "USER ADDED... PRESS [ENTER] TO GOTO HOMESCREEN" elif z is False: print "USER WAS NOT ADDED... PRESS [ENTER] TO GOTO HOMESCREEN" raw_input() home()
def register(): if request.method == 'GET': return flask.render_template('register.html') email = request.form['email'] password = request.form['password'] confirmation = request.form['confirmation_password'] league_password = request.form['league_password'] if password != confirmation: return flask.render_template( 'register.html', error_msg='Your password did not match the confirmation') if league_password != settings.league_password: return flask.render_template('register.html', error_msg='Bad league password') session['email'] = email db.new_user(email, sha.sha(password).hexdigest(), email) if db.num_users() == 1: return redirect( "https://fiesta.cc/authorize?state=create_group&response_type=code&client_id=%s&_register_email=%s" % (settings.client_id, email)) else: fiesta.add_member(email) return redirect('/homepage')
def register(): if request.method == 'POST': key = keymgmt.create_new_key() db.new_user(request.form['name'], apikey=key) return render_template('registered.html', name=request.form['name'], apik=key) else: return render_template('register.html')
def start_message(message): bot.send_message( message.chat.id, 'Вітаю, {0.first_name} ! \nЯ створений, щоб допомагати тобі орієнтуватися по навчальному процесі.' .format(message.from_user, bot.get_me()), parse_mode='html') bot.send_message( message.chat.id, "Якщо ти знайшов помилку напиши моєму творцю: @P0wer_bla4er", reply_markup=keyboards.main_keyboard) db.new_user(user_id=message.chat.id) db.search_teacher_mode(message.chat.id, 'off')
def start_message(message): """Greeting of useer when he first time in bot. And also create entry in database for his information Args: message: answer from telegram api. """ chat_id = message.chat.id bot.send_message( message.chat.id, messages.intro_message, reply_markup=keyboard_main, ) if not db.user_exists(chat_id): db.new_user(chat_id, message.from_user.username)
def register(): if request.method == "GET": return render_template("register.html") else: try: if not require_fields("username", "password", "email"): raise AppError("必填项未填") db.new_user(request.form["email"], request.form["username"], request.form["password"]) return redirect("/") except AppError as e: db.log("register_failure", username=request.form.get("username"), email=request.form.get("email")) return render_template("register.html", errors=(e.message, ))
def adduser(): try: conn = db.create_connection(config.DBFile()) if request.form['name'] and request.form['tag'] and request.form[ 'email'] and request.form['phone']: retval = db.new_user(conn, request.form['tag'], request.form['email'], request.form['phone'], request.form['name']) if retval == -1: return render_template( 'message.html', message=_('Are you sure you\'re not already registered?')) elif retval == -2: return render_template( 'message.html', message=_('Something went wrong, try again later')) else: return render_template('message.html', message=_('Welcome, ') + request.form['tag']) else: return render_template('message.html', message=_('Missing some items...')) except: return render_template( 'message.html', message=_('Something wrong happened!<br />Already registered?'))
def register(): if "uid" in session: return redirect("/") if request.method == "GET": return render_template("register.html") if request.method == "POST": username = request.form["username"] password = request.form["password"] confirm_password = request.form["confirm-password"] period_1 = request.form["period-1"] period_2 = request.form["period-2"] period_3 = request.form["period-3"] period_4 = request.form["period-4"] period_5 = request.form["period-5"] period_6 = request.form["period-6"] period_7 = request.form["period-7"] period_8 = request.form["period-8"] period_9 = request.form["period-9"] period_10 = request.form["period-10"] if db.username_taken(username): flash("Username " + username + " is already taken.") return render_template("register.html") if password != confirm_password: flash("Passwords don't match.") return render_template("register.html") new_uid = db.new_user(username, password, (period_1, period_2, period_3, period_4, period_5, period_6, period_7, period_8, period_9, period_10)) session["uid"] = new_uid return redirect(url_for("user", id=new_uid))
def register(): if request.method == 'GET': return render_template('register.html') button = request.form['button'] username = request.form['username'] password = request.form['password'] if button == 'cancel': return redirect('/') else: criteria = {'username': username} if db.find_user(criteria): return render_template('register.html',error=True) else: user_params = {'username': username, 'password': password} db.new_user(user_params) session['username'] = username return redirect('/')
def register(): if not app.config['allow_register']: abort(403) if request.method == 'GET': if session.get('username'): return redirect(url_for('.show_all')) else: return render_template('register.html', username='', display='') else: form = request.form if session.get('username'): return redirect(url_for('.show_all')) elif len(form.get('username', '')) and len(form.get('password', '')) \ and len(form.get('display', '')): username = form['username'] password = form['password'] display = form['display'] if not re.match('^[a-zA-Z]{3,20}$', username): flash('Invalid username. Must be alphabetic with ' + '3-20 characters.') return render_template('register.html', username=username, display=display) user = db.get_user(username) if user: flash('Username is taken!') return render_template('register.html', username=username, display=display) else: db.new_user(username, password, display, True) flash('Registered new account: ' + username + ', ' + display) return redirect(url_for('.show_all')) else: missing = [] if len(form.get('username', '')) == 0: missing.append('username') if len(form.get('password', '')) == 0: missing.append('password') if len(form.get('display', '')) == 0: missing.append('display name') joined = ' & '.join(missing) if len(missing) < 3 else \ '%s, %s & %s' % (missing[0], missing[1], missing[2]) flash('Missing ' + joined + '!') return redirect(url_for('.register'))
def signup(): if request.method == 'POST': if not db.new_user(request.form['username'], request.form['password']): return 'Username {} Taken'.format(request.form['username']) db.edit_balance(request.form['username'], 10000, 100) return redirect('/login') elif request.method == 'GET': with open('signup.html', 'r') as f: return f.read()
def get_email(): if request.method == 'GET': email = request.args.get('email', default='invalid email') if check(email): uid = check_for_email(email) if get_user(uid): huid = hash.user_safe_hash(uid) existing_email(email, huid) return jsonify({ 'success': False, 'message': 'This email address is already in use. We have \ sent you an email to log in to access your info' }) pin = ''.join(random.choice('0123456789') for _ in range(6)) new_email(email, pin) new_user(email, pin) return jsonify({ 'success': True, 'message': 'Please enter the 6-digit email sent to you to continue.' }) else: return jsonify({ 'success': False, 'message': 'Please enter a valid email address' }) else: email = request.form.get('email', default="nope") pin = request.form.get('pin', default=123456) if validate_user(email, pin): uid = uuid.uuid4().hex create_user(uid, email) huid = hash.user_safe_hash(uid) existing_email(email, huid) return jsonify({'success': True, 'uid': huid}) return jsonify({ 'success': False, 'message': '6 digit pin does not match. Please try again.' })
def post(self): email = self.get_argument('email') account = self.get_argument('account') pwd = self.get_argument('pwd1') res, uid = db.new_user(email, account, pwd) if res == 1: self.set_secure_cookie('user', str(uid)) self.redirect('/home') else: self.redirect('/signup')
def sign_up(self, email, password): try: user_id = db.new_user(email=email, password=password) self.set_secure_cookie('user_id', user_id) mail.send_mail( recipients=[email], subject='Welcome to tymdrop!', content='Welcome to http://www.tymdrop.com') except IntegrityError: raise web.HTTPError(400, reason="That email address is already taken")
def add_offer(message, shop, item): """add dungling offer that user need to approve Args: message (): bounty shop (str): shop for offer item (str): item for offer """ chat_id = message.chat.id bounty = message.text # Если юзер не прожимал старт во время запуска бота(хз как) создаем его док в базе if db.user_exists(chat_id): db.add_dungling_offer(chat_id, shop, item, bounty) else: db.new_user(chat_id, message.from_user.username) db.add_dungling_offer(chat_id, shop, item, bounty) bot.send_message(chat_id, messages.print_offer.format(shop, item, bounty), reply_markup=keyboard_confirmation)
def new_post(message): pid = getid.getuuid() uid = message.from_user.id dbcode = db.new_user(pid,uid) if dbcode == 0: dbcode = db.new_po(pid) if dbcode == 0: bot.send_message(message.chat.id,u'新的抽奖已经准备就绪,抽奖口令:\n`%s`'%pid,parse_mode='Markdown') else: bot.send_message(message.chat.id,'遇见错误,抽奖未能成功创建',parse_mode='Markdown') else: bot.send_message(message.chat.id,'遇见错误,抽奖未能成功创建',parse_mode='Markdown')
def register(): if request.method == 'GET': return render_template('register.html') button = request.form['button'] username = request.form['username'] password = request.form['password'] first = request.form['first'] last = request.form['last'] if button == 'cancel': return redirect('/') else: if not password or not first or not last: return render_template('register.html',error='incomplete') criteria = {'username': username} if db.find_user(criteria): return render_template('register.html',error='username taken') else: initial_Schedule= ["N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","","","","","","","","","",""] user_params = {'username': username, 'password': password, 'first': first, 'last': last, 'schedule':initial_Schedule, 'essays':[],'Message':[]} db.new_user(user_params) session['username'] = username return redirect('/')
def home_newuser(): """The new user menu""" print "=====================" print "--->NEW USER MENU<---" print "=====================" newfname = raw_input("NEW USER FIRST NAME: ") if newfname == ":EXIT": home() else: pass newlname = raw_input("NEW USER LAST NAME: ") today = raw_input("MARK PRESENT FOR TODAY [Y/N] ") if today in ("Y","y"): db.new_user(newfname,newlname,True) print "USER ADDED... PRESS [ENTER] TO GOTO HOMESCREEN" raw_input() elif today == ":EXIT": home() else: db.new_user(newfname,newlname,False) print "USER ADDED... PRESS [ENTER] TO GOTO HOMESCREEN" raw_input() home()
def register(): if request.method == 'GET': return render_template('register.html') button = request.form['button'] username = request.form['username'] password = request.form['password'] first = request.form['first'] last = request.form['last'] if button == 'Cancel': return redirect('/') else: if not password or not first or not last: return render_template('register.html',error='incomplete') criteria = {'username': username} if db.find_user({'username':username}): return render_template('register.html',error='username taken') else: user_params = {'username': username, 'password': password, 'first': first, 'last': last} db.new_user(user_params) return redirect('/')
def new_user(user): import db user = dict(user) db.new_user(user) return True
import db, sha db.new_user('dan', sha.sha('dan').hexdigest(), 'Daniel Gottlieb')