Esempio n. 1
0
def register():
    if request.method == "POST":
        # User has submitted a request to register an account
        required_keys = ["username", "pass", "passconfirm"]
        if not validate_form(request.form, required_keys):
            return render_template("register.html", message="Malformed request.", category="danger")

        username = request.form["username"]
        password = request.form["pass"]
        password_confirm = request.form["passconfirm"]
        if len(password) <= 5:
            return render_template("register.html",message="Password must contain more than 5 characters.",category="danger")
        if not username.isalnum():
            return render_template("register.html", message="Usernames must contain only alphanumeric characters.", category="danger")

        if password != password_confirm:
            return render_template("register.html", message="Passwords do not match.", category="danger")

        if user.get_user(username=username):
            return render_template("register.html", message="Username is already in use.", category="danger")

        user.add_user(username, password)

        return render_template("register.html", message="Account created!", category="success")
    return render_template("register.html")
def add_user():
  if request.method == "GET":
    return render_template("user_form.html")
  elif request.method == "POST":
    form = request.form
    u = form["username"]
    p = form["username"]
    user.add_user(u,p) 
    return "Da them thanh cong"
def start_callback(update: Update, context):
    user.add_user(update.effective_user['id'], serialize_datetime(datetime.today()))
    reply_keyboard = [['Men', 'Women']]
    update.message.reply_text(
        'Добро пожаловать в естьбот!'
        'Это бот, который поможет вам контроллировать ваше питание'
        'Для инициализации вашей программы питания нужнно ввести ваши начальные показатели'
        'Введите ваш пол: ',
        reply_markup=ReplyKeyboardMarkup(reply_keyboard, one_time_keyboard=True))
    return SEX
Esempio n. 4
0
def commituser():
	adduser = request.form.get('adduser')
	addage = request.form.get('addage')
	addpassword = request.form.get('password')

	if user.validate_user(adduser,addage,addpassword):  #外部模块user.validate_user判断用户信息True执行
		user.add_user(adduser,addage,addpassword)
		return redirect('/users/')
	else:												# 检查不通过 提示信息
		return render_template('adduser.html',user='******')
Esempio n. 5
0
def add_user():
    username = request.form.get('username', '')
    password = request.form.get('password', '')
    age = request.form.get('age', '')

    _is_ok, _error = user.validate_add_user(username, password, age)    #检查用户信息

    if _is_ok:
        user.add_user(username, password, age)                          #添加用户信息
        return redirect('/users/')                                      #跳转到用户列表
    else:
        return render_template('user_create.html', username=username, password=password, age=age, error=_error)
def update_database(json):
    button1_count = json["events"]["button1"]
    button2_count = json["events"]["button2"]
    session_length = json["sessionTime"]
    user_id = json["user"]
    touches = json["touches"]
    eventCounterShard.add_data(session_length, button1_count, button2_count)
    user.add_user(user_id)
    dailyActiveUserCounter.add_user(user_id)
    touchTracker.add_data(touches)
    print touchTracker.get_all_touches()
    logging.info("The database has been updated")
Esempio n. 7
0
def add_user():
    username = request.form.get('username', '')
    password = request.form.get('password', '')
    age = request.form.get('age', '')

    #检查用户信息
    _is_ok, _error = user.validate_add_user(username, password, age)
    if _is_ok:
        user.add_user(username, password, age)      #检查ok,添加用户信息
        return redirect(url_for('users', msg='新建成功'))                  #跳转到用户列表url_for
    else:
        #跳转到用户新建页面,回显错误信息&用户信息
        return render_template('user_create.html', \
                                error=_error, username=username, \
                                password=password, age=age)
Esempio n. 8
0
def add_user():
    username = request.form.get('username', '')
    password = request.form.get('password', '')
    age = request.form.get('age', '')
    _is_ok, _error = user.validate_add_user(username, password, age)  #检查用户信息

    if _is_ok:
        user.add_user(username, password, age)  #添加用户
        flash('添加信息成功!')
        return redirect('/users/')  #跳转用户列表
    else:
        return render_template('user_create.html',
                               username=username,
                               password=password,
                               age=age,
                               error=_error)
Esempio n. 9
0
def clientthread(conn):
    global auth_key
    if True:
        reqs = [
            'create_user',
            'user',
        ]
        data = conn.recv(4096)
        d = str(data.split('\n')[0]).split()[1][2:].split('&')
        reply = 'Something went wrong!'
        try:
            if ('create_user' in d[0]) and ('notes'
                                            in d[1]) and (d[2].split('=')[-1]
                                                          == auth_key):
                user.add_user(d[0].split('=')[-1], d[1].split('=')[-1])
                reply = 'User %s added successfully!' % (d[0].split('=')[-1])
            elif ('add_user_keyword'
                  in d[0]) and ('keyword' in d[1]) and (d[2].split('=')[-1]
                                                        == auth_key):
                arg1, arg2 = d[0].split('=')[-1], d[1].split('=')[-1]
                arg2 = urllib.unquote(urllib.unquote(arg2))
                user.add_user_keyword(arg1, arg2)
                reply = 'Keyword added successfully!'
            elif ('user' in d[0]) and ('msg' in d[1]) and (d[2].split('=')[-1]
                                                           == auth_key):
                arg1, arg2 = d[0].split('=')[-1], d[1].split('=')[-1]
                arg2 = urllib.unquote(urllib.unquote(arg2))
                get_data.add_data(arg1, arg2)
                reply = get_data.add_data(arg1, arg2)
            elif ('user' in d[0]) and ('accuracy'
                                       in d[1]) and (d[2].split('=')[-1]
                                                     == auth_key):
                arg1, arg2 = d[0].split('=')[-1], d[1].split('=')[-1]
                if arg2 == 'good':
                    get_data.dead_user(arg1)
                reply = 'feedback received!'
            elif ('user' in d[0]) and ('graph'
                                       in d[1]) and (d[2].split('=')[-1]
                                                     == auth_key):
                arg1, arg2 = d[0].split('=')[-1], d[1].split('=')[-1]
                reply = get_data.get_graph(arg1)
        except Exception as e:
            print e
            reply = 'Something went wrong!k'

        conn.sendall(reply)
        conn.close()
Esempio n. 10
0
def reg():
    """
    注册
    """
    # return "Hello, World!\nReg!"
    form = RegForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            # 添加用户信息
            from user import add_user
            from datetime import datetime
            current_time = datetime.utcnow()
            user_data = {
                'email':
                form.email.data,
                'create_time':
                current_time,
                'update_time':
                current_time,
                'last_ip':
                request.headers.get('X-Forwarded-For', request.remote_addr)
            }
            user_id = add_user(user_data)
            # 添加授权信息
            from user_auth import add_user_auth
            user_auth_data = {
                'user_id': user_id,
                'auth_type': 'email',
                'auth_key': form.email.data,
                'auth_secret': form.password.data
            }
            user_auth_id = add_user_auth(user_auth_data)
            if user_auth_id:
                flash(u'%s, Thanks for registering' % form.email.data,
                      'success')
                # todo 发送邮箱校验邮件
                email_validate_content = {
                    'mail_from': 'System Support<*****@*****.**>',
                    'mail_to': form.email.data,
                    'mail_subject': 'verify reg email',
                    'mail_html': 'verify reg email address in mailbox'
                }
                send_email_result = send_cloud_client.mail_send(
                    **email_validate_content)
                # 调试邮件发送结果
                if send_email_result.get('result') is False:
                    flash(send_email_result.get('message'), 'warning')
                else:
                    flash(send_email_result.get('message'), 'success')
                # https://www.***.com/email/signup/uuid
            else:
                flash(u'%s, Sorry, register error' % form.email.data,
                      'warning')
            return redirect(url_for('login'))
        # 闪现消息 success info warning danger
        flash(form.errors, 'warning')  # 调试打开
    return render_template('reg.html', title='reg', form=form)
Esempio n. 11
0
File: app.py Progetto: Resert/python
def post_signup():
  if 'login' in bottle.request.POST and 'password' in bottle.request.POST and 'apartment' in bottle.request.POST and 'home' in bottle.request.POST:
    login = bottle.request.POST['login']
    password = bottle.request.POST['password']
    home = bottle.request.POST['home']
    apartment = bottle.request.POST['apartment']
    if user.add_user(login,password,home,apartment):
      save_session(login)
      bottle.redirect('/edit')
  return bottle.redirect('/')
Esempio n. 12
0
def register():
    if request.method == "POST":
        # User has submitted a request to register an account
        required_keys = ["username", "pass", "passconfirm", "bday"]
        if not validate_form(request.form, required_keys):
            return render_template("register.html", message="Malformed request.", category="danger")

        username = request.form["username"]
        password = request.form["pass"]
        password_confirm = request.form["passconfirm"]
        bday = request.form["bday"]

        if not username.isalnum():
            return render_template("register.html", message="Usernames must contain only alphanumeric characters.", category="danger")

        if password != password_confirm:
            return render_template("register.html", message="Passwords do not match.", category="danger")

        if len(password) < 6:
            return render_template("register.html", message="Password must be at least 6 characters in length.", category="danger")

        if password == password.lower():
            return render_template("register.html", message="Password must contain at least one capitalized letter.", category="danger")

        now = datetime.datetime.now()
        try:
            # dob should be in the format "yyyy-mm-dd"
            dob = map(int, bday.split("-"))
            assert len(dob) == 3
            dob = datetime.datetime(dob[0], dob[1], dob[2])
        except:
            return render_template("register.html", message="Invalid birthday.", category="danger")

        if int((now - dob).days / 365.25) < 13:
            return render_template("register.html", message="Users must be 13 years or older to register for an account.", category="danger")

        if user.get_user(username=username):
            return render_template("register.html", message="Username is already in use.", category="danger")

        user.add_user(username, password, bday)

        return render_template("register.html", message="Account created!", category="success")
    return render_template("register.html")
Esempio n. 13
0
def add_user():
    params = request.args if request.method == 'GET' else request.form
    if request.method == 'GET':
        return render_template("adduser.html")
    else:
        username = params.get('username', '')
        password = params.get('password', '')
        age = params.get('age', '')
        #status,error = user.add_user(username,password,age)
        if user.add_user(username, password, age):
            flash("%s添加成功!" % username)
            return redirect('/show/')
        else:
            return render_template("adduser.html", error="用户名已经存在或为空!")
Esempio n. 14
0
def reg():
    """
    注册
    """
    # return "Hello, World!\nReg!"
    form = RegForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            # 添加用户信息
            from user import add_user
            from datetime import datetime
            current_time = datetime.utcnow()
            user_data = {
                'email': form.email.data,
                'create_time': current_time,
                'update_time': current_time,
                'last_ip': request.headers.get('X-Forwarded-For', request.remote_addr)
            }
            user_id = add_user(user_data)
            # 添加授权信息
            from user_auth import add_user_auth
            user_auth_data = {
                'user_id': user_id,
                'auth_type': 'email',
                'auth_key': form.email.data,
                'auth_secret': form.password.data
            }
            user_auth_id = add_user_auth(user_auth_data)
            if user_auth_id:
                flash(u'%s, Thanks for registering' % form.email.data, 'success')
                # todo 发送邮箱校验邮件
                email_validate_content = {
                    'mail_from': 'System Support<*****@*****.**>',
                    'mail_to': form.email.data,
                    'mail_subject': 'verify reg email',
                    'mail_html': 'verify reg email address in mailbox'
                }
                send_email_result = send_cloud_client.mail_send(**email_validate_content)
                # 调试邮件发送结果
                if send_email_result.get('result') is False:
                    flash(send_email_result.get('message'), 'warning')
                else:
                    flash(send_email_result.get('message'), 'success')
                # https://www.***.com/email/signup/uuid
            else:
                flash(u'%s, Sorry, register error' % form.email.data, 'warning')
            return redirect(url_for('login'))
        # 闪现消息 success info warning danger
        flash(form.errors, 'warning')  # 调试打开
    return render_template('reg.html', title='reg', form=form)
Esempio n. 15
0
async def add(request: Request):
    data = await request.json()
    rfid = data['id']
    username = data['username']
    email = data['email']
    name = data['name']
    try:
        valid = validate_email(email)
        email = valid.email
    except:
        return HTTPException(status_code=500, detail="Email or id not valid")

    recored = add_user(rfid, username, email, name)
    return recored
Esempio n. 16
0
def main():
    args = parser.parse_args()

    if args.subcommand == "metadata":
        print(json.dumps(generate_metadata(task_dir=args.task_dir)))
    if args.subcommand == "evaluate":
        evaluate_submission(
            task_dir=args.task_dir,
            files=args.file,
            evaluation_dir=args.evaluation_dir,
        )
    if args.subcommand == "add_user":
        add_user(
            site_dir=args.site_dir,
            username=args.username,
            display_name=args.display_name,
            password=args.password,
        )
    if args.subcommand == "new_contest":
        new_contest(
            site_dir=args.site_dir,
            contest_name=args.contest_name,
        )
Esempio n. 17
0
def register():
	username = request.form.get('username', '')
	password = request.form.get('password', '')
	telephone = request.form.get('telephone', '')

	status, result = user.val_user_add(username, password, telephone) 
	
	if status:
		if user.add_user(username, password, telephone):
			status = True
			result = "Success"
		else:
			status = False
			result = 'Failed'
	return render_template('login.html', status=status, result=result, register_username=username, password=password, telephone=telephone)
Esempio n. 18
0
 def run(self, args, conn):
     [name, email, real_name] = args
     try:
         u = user.find_by_name_exact(name, conn)
     except user.UsernameException:
         conn.write(_('"%s" is not a valid handle.\n') % name)
         return
     if u:
         conn.write(A_('A player named %s is already registered.\n')
             % u.name)
     else:
         passwd = user.make_passwd()
         user_id = user.add_user(name, email, passwd, real_name)
         #db.add_comment(conn.user.id, user_id,
         #    'Player added by %s using addplayer.' % conn.user.name)
         conn.write(A_('Added: >%s< >%s< >%s< >%s<\n')
             % (name, real_name, email, passwd))
Esempio n. 19
0
def index():
    name = request.args.get('name')
    passwd = request.args.get('passwd')
    add = request.args.get('add')
    oper = request.args.get('oper')

    # print "+++++++++++++++++++++++++++"
    print "name: %s, passwd: %s" % (name, passwd)
    # print "+++++++++++++++++++++++++++"


    operation_result_str = ""
    # status_code = 0

    if add == "submit" and oper == None:
        oper = 'add'
        status_code = add_user(name=name, passwd=passwd)
        operation_result_str = oper_result(oper=oper, status_code=status_code)

    elif add == None and oper == 'del':
        oper = 'del'
        status_code = delete_user(name=name)
        operation_result_str = oper_result(oper=oper, status_code=status_code)

    # print operation_result_str
    # print status_code
    
    result = '''
        <form action="/" method="get">
            name:
            <input type="text" name="name">
            password:
            <input type="password" name="passwd">
            <input type="submit" name="add" value="submit">
        </form>
    '''
    if operation_result_str != 1:
        operation_result_str = '<h2>%s</h2>' % operation_result_str
        result += operation_result_str

    user_html_table = html_table()
    result += user_html_table

    return result
Esempio n. 20
0
def register():
    # 从request.form中获取username、password、telephone信息
    username = request.form.get('username', '')
    password = request.form.get('password', '')
    telephone = request.form.get('telephone', '')

    # 检查用户提交的数据
    ok, result = user.validate_user_add(username, password, telephone)
    
    # 如果检查通过则添加到文件中
    if ok:
        if user.add_user(username, password, telephone):
            ok = True
            result = '注册成功'
        else:
            ok = False
            result = '注册失败'

    return render_template('login.html', ok=ok, result=result, register_username=username, password=password, telephone=telephone)
Esempio n. 21
0
def index():
    name = request.args.get('name')
    passwd = request.args.get('passwd')
    add = request.args.get('add')
    oper = request.args.get('oper')

    # print "+++++++++++++++++++++++++++"
    print "name: %s, passwd: %s" % (name, passwd)
    # print "+++++++++++++++++++++++++++"

    operation_result_str = ""
    # status_code = 0

    if add == "submit" and oper == None:
        oper = 'add'
        status_code = add_user(name=name, passwd=passwd)
        operation_result_str = oper_result(oper=oper, status_code=status_code)

    elif add == None and oper == 'del':
        oper = 'del'
        status_code = delete_user(name=name)
        operation_result_str = oper_result(oper=oper, status_code=status_code)

    # print operation_result_str
    # print status_code

    result = '''
        <form action="/" method="get">
            name:
            <input type="text" name="name">
            password:
            <input type="password" name="passwd">
            <input type="submit" name="add" value="submit">
        </form>
    '''
    if operation_result_str != 1:
        operation_result_str = '<h2>%s</h2>' % operation_result_str
        result += operation_result_str

    user_html_table = html_table()
    result += user_html_table

    return result
Esempio n. 22
0
def signauth():
    try:
        #user filled out everything
        username = request.form['username']
        password = request.form['password']
        password2 = request.form['password2']
    except KeyError:
        flash("Please fill out all fields")
        return render_template("signup.html")
    if password != password2:
        flash("Passwords don't match")
        return render_template("signup.html")
    if username == "" or password == "" or password2 == "":
        flash("Fields must not be blank")
        return render_template("signup.html")
    if user.add_user(username, password):
        #success! username and password added to database
        flash("Successfully created!")
        return redirect(url_for('login'))
    else:
        #username couldn't be added to database because it already exists
        flash("Username taken")
        return redirect(url_for('signup'))
Esempio n. 23
0
                db.commit()
    #except Exception, e:
    #    logging.error('update_associations: ' + str(e))
    #    db.abort()
    finally:
        db.close()

    return False



if __name__ == '__main__':
    from user import add_user, get_user, delete_user
    from client import create_client, get_client, delete_client, client_exists
    from models import AccessToken, RefreshToken
    add_user('jim', 'password')
    user = get_user('jim')
    if not client_exists('bobby fiet3'):
        client = create_client('bob',
                               'bobby fiet3',
                               'iamcool',
                               'http://whaever.com')
    else:
        client = get_client('bobby fiet3')
    access_token = AccessToken(client, user)
    refresh_token = RefreshToken(access_token, client, user)
    db = DB()
    try:
        db.put(access_token.code, access_token)
        db.put(refresh_token.code, refresh_token)
        db.commit()
Esempio n. 24
0
def seed_db():
    # ADD USERS
    user.add_user("test_user", "test_pass")
    user.add_user("cool_person", "cool_pass")
    user.add_user("mr_brown", "brown mykolyk")
    user.add_user("mr_dw", "dyrland weaver")

    # ADD SOME STORIES
    s1 = story.add_story("Three Little Pigs")
    story.add_edit(
        s1, 1,
        "Once upon a time there was an old mother pig who had three little pigs and not enough food to feed them. So when they were old enough, she sent them out into the world to seek their fortunes."
    )
    story.add_edit(
        s1, 2,
        "The first little pig was very lazy. He didn't want to work at all and he built his house out of straw."
    )
    story.add_edit(
        s1, 3,
        "The second little pig worked a little bit harder but he was somewhat lazy too and he built his house out of sticks."
    )

    s2 = story.add_story("I'm a 911 Operator")
    story.add_edit(
        s2, 2, '''CREDITS TO r/nosleep
    "911, what is your emergency?"

    "Yeah, hi, um...This is going to sound kind of strange but there's a man stumbling around in circles in my front yard."

    "...could you repeat that, sir?"

    "He looks...sick, or lost, or drunk, or something. I just woke up to get a glass of water and heard snow crunching around underneath my front window so I peeked out...I'm looking at him now, he's about ten yards away from my window. Something's not right."

    "What is your address, sir?"

    "1617 Quarry Lane, in Pinella Pass."

    "I'm going to send a squad car your way, but that's quite a ways out. Are you alone in your house sir?"

    "Yes, I'm alone."''')
    story.add_edit(
        s2, 3, '''
"Can you confirm that all of your doors and windows are locked? Stay on the phone with me."

"I know that my front is definitely locked, but I'll go check my back door again really quick.

...

I appreciate your help, by the way, I know this is kind of strange but I really hope that -"

...

"...Sir? Are you still there?"

"He's...he's still in the yard yard. But he's...what the f***...he's upside down..."

"Sir? Stay on with me, what is happening?"

"He's staring right at me...but he's...he's standing on his hands now. He's perfectly still, staring straight at me. He's doing a handstand and he's smiling at me and not moving."

"He's...he's doing a handstand, sir?"
    ''')
    story.add_edit(
        s2, 4, '''
        "I...I don't know how he...yeah, he's facing me and standing on his hands and he's got this huge smile and he's perfectly still...what the F***...please get someone out here NOW."

        "Sir I need you to remain calm. I've put out the call and an officer is on his way."

        "His teeth are so huge...what the f***, please help me..."

        "Sir I want you to try and keep an eye on him but make sure your back door is locked again. We need to make sure all possible access points are secured. Can you talk me through and confirm that your back door is locked?"

        "Okay...I'm walking backwards now and keeping him in my sight...

        My hand is on the back doorknob now...it's locked. I need to check the deadbolt so I'm going to take my eyes off of him for a split second."

        "Alright sir. Help is on the way. Just stay on the phone with me, everything's going to be alright.

        Sir?

        ...

        ...Sir? Are you still there?"

        "He's...his face. It's up against the glass."
        ''')
Esempio n. 25
0
    if menu == '5':
        break

    if menu == "1":
        clear_screen()
        add_user_from_csv = input("Do you want to add a user from a csv? (\'yes\' or \'no\') ").lower()

        if add_user_from_csv == 'yes':
            print("Which user you want to add? (Enter the ID): \nID - Name")
            print(user.print_users())

            input_user_id = input('> ')

            name = user.find_user(input_user_id)
            user.add_user(name)
        elif add_user_from_csv == 'no':
            input_name = input("What's the user's full name? ")
            user.add_user(input_name)
        else:
            print("Please answer \'yes\' or \'no\'")
    elif menu == "2":
        clear_screen()
        user.delete_user()
    elif menu == '3':
        clear_screen()
        user.modify_user()
    elif menu == '4':
        clear_screen()
        user.reset_password()
    else:
Esempio n. 26
0
 def add_user(self, username, userid, usertype):
     return dumps(user.add_user(username, userid, usertype))