예제 #1
0
def _user_must_not_exist(user):
	''' ensures name doesn't already exist in db '''

	user = format_text(user)

	if user_exists(user):
		raise ValidationError('This name has already been taken.')
예제 #2
0
def process_web_signup(name, number):
    # generate random verif_code
    verif_code = randint(100000,999999)
    number = "+1" + number

    # if user exists (but in not active), update verif
    if user_exists(parse.format_text(name)):
        set_verif(number, verif_code)
    else:
        # store user in db, delete if verif is wrong
        create_user(name, number)
        set_verif(number, verif_code)

    # send the user an SMS with the verif_code
    send_verif(number, verif_code)
예제 #3
0
def _process_valid_message(body, number):
    from_name = get_name_from_number(number)
    from_phone = number
    message_body = parse.get_message_body(body)
    to_name = parse.get_message_to(body)
    # TODO: not random ID
    guess_id = str(random.randint(1,99999))  # we sms g_id out so people can guess!

    # if we know tagged user, we will forward the text body
    if user_exists(user_name):
        to_phone = get_number_from_name(user_name)
        create_message(from_name, from_phone, message_body, to_name, to_phone, guess_id)        
        send_message_and_id(message_body, guess_id, to_number) # send the text! 
    # user doesn't exist but we save the message body anyway
    else:
        to_phone = ''
        create_message(from_name, from_phone, message_body, to_name, to_phone, guess_id)
예제 #4
0
def login():
    if request.method == 'GET':
        log_out_user()
        return render_template('FrontEndLogin.html')
    if request.method == 'POST':
        user_name = request.form.get('username')
        user_password = request.form.get('password')
        user_exists_res = user_exists(user_name, user_password)
        if user_exists_res == True:
            #return render_template('login.html', result = 'Login Success')
            global logged_in_user
            logged_in_user = user_name
            global user_logged_in
            user_logged_in = True
            return redirect(url_for('home'))
        else:
            return render_template('FrontEndLogin.html', result='Login Failed')