Exemplo n.º 1
0
def register():
    username = raw_input("Username : "******"Password : "******"Repeat password : "******"Email : ")

    phash = md5.new(password).hexdigest()
    rphash = md5.new(repeat_password).hexdigest()

    if phash != rphash:
        print "Passwords dont match! Sorry..."
    else:
        db.create_new_user(username, phash, email)
Exemplo n.º 2
0
def register():
    if request.method == 'GET':
        return render_template('register.html')
    elif request.method == 'POST':
        form = request.form
        username = form.get('username')
        email = form.get('email')
        password = form.get('password')
        exist_user = db.get_user_by_name(username)
        if exist_user:
            return render_template('register.html', message='Name already been used!')
        else:
            db.create_new_user(username, email, password)
            return redirect('/login')
Exemplo n.º 3
0
def start(update, context):
    username = update.message.from_user.username
    
    if not check_if_user_exists(session, username):
        create_new_user(session, username)

    reply_text = f'''Hey there, {username}!
    I\'m a deadpan simple bot for appending text to Notion page.
    Use /help to get the instructions. 

    Now, let's set me up for work!
    '''
    update.message.reply_text(reply_text, reply_markup=keyboard)
    setup(update, context)
    return ConversationHandler.END
Exemplo n.º 4
0
def start(update, context):
    username = update.message.from_user.username

    if not db.check_if_user_exists(session, username):
        db.create_new_user(session, username)

    update_user_data(update, context, session)

    reply_text = f''' Otgovorki Bot {BOT_VERSION}.
    Привет, {username}!
    Я - бот для генерации отговорок отговорок и отмазок.
    Иногда ошибаюсь - зато смешно ;)
    Справка по моим командам: /help .
    '''
    update.message.reply_text(reply_text, reply_markup=keyboard)
    return ConversationHandler.END
Exemplo n.º 5
0
Arquivo: jhkg.py Projeto: neynt/jhkg
def register_action():
    user = request.form["username"]
    email = request.form["email"]
    pswd = request.form["password"]
    school = request.form["school"] or 'summa cum laude from MIT'
    result = db.create_new_user(user, pswd, email, school)
    if result == 'user exists':
        return "That username already exists."
    elif result == 'email exists':
        return "Someone already registered with that email!"
    elif result == 'empty fields':
        return "Please fill in all required fields."
    elif result == 'success':
        return "Welcome to the club."
    else:
        return result
Exemplo n.º 6
0
Arquivo: jhkg.py Projeto: neynt/jhkg
def register_action():
    user = request.form["username"]
    email = request.form["email"]
    pswd = request.form["password"]
    school = request.form["school"] or "summa cum laude from MIT"
    result = db.create_new_user(user, pswd, email, school)
    if result == "user exists":
        return "That username already exists."
    elif result == "email exists":
        return "Someone already registered with that email!"
    elif result == "empty fields":
        return "Please fill in all required fields."
    elif result == "success":
        return "Welcome to the club."
    else:
        return result
Exemplo n.º 7
0
def signup():
    error = None
    if request.method == 'POST':
        username = request.form['username']
        hashed_pw = generate_password_hash(request.form['password'])

        try:
            new_user_id = db.create_new_user(username, hashed_pw)

            session['logged_in'] = True
            session['username'] = username
            session['user_id'] = new_user_id
            flash('New user successfully created and signed in')
            return redirect(url_for('profile', username=username))
        except db.OperationException as e:
            error = e.message
    return render_template('signup.html', error=error)
Exemplo n.º 8
0
def register():
    """creates a new user who will be allowed to access the database.

    Args:
        username (str): name of the user to be saved in the database.
        password (str): password of the user to be saved in the database.

    Returns:
        if all goes well:
            dict: {}
            Bool: True
        if something goes wrong:
            dict: Error message.
            Bool: False
    """
    json = request.get_json()

    username = json.get('username')
    password = json.get('password')

    if not username:
        return jsonify({"msg": "Missing username parameter"}), 400
    if not password:
        return jsonify({"msg": "Missing password parameter"}), 400

    user, success = db.get_user_by_username(username)

    if not success:
        return {
            "msg": 'The server found an error that it could not handle'
        }, 500

    if user:
        return {"msg": "username already exists"}, 409

    hash_password = sha1(password.encode('utf-8')).hexdigest()

    if not db.create_new_user(username, hash_password):
        return {
            "msg": 'The server found an error that it could not handle'
        }, 500

    return {}, 204
Exemplo n.º 9
0
    def __init__(self,mail="*****@*****.**"):
        self.uid = db.get_user_id(mail)

        if self.uid < 0 :
            self.uid = db.create_new_user(mail)
Exemplo n.º 10
0
    def __init__(self, mail="*****@*****.**"):
        self.uid = db.get_user_id(mail)

        if self.uid < 0:
            self.uid = db.create_new_user(mail)