def test_wrong_combination(self):
     username = str(random.randint(1,10000000000000))
     password = '******'
     add_user(username, password)
     self.assertFalse(find_user(username,password[:-1]))
     self.assertFalse(find_user(username[:-1],password))
     self.assertFalse(find_user(username[:-1],password[:-1]))
示例#2
0
文件: bot.py 项目: world1dan/Rebot
def allow(c):
    try:
        id = int(c.data.replace('allow', ''))
        database.add_user(id)
        database.add_marks_user(id)
        bot.answer_callback_query(callback_query_id=c.id,
                                  show_alert=True,
                                  text=f"{id} Получил доступ к боту")
        bot.send_sticker(c.from_user.id, config.stickers['wait-2'])
        bot.send_message(
            id,
            'Заявка принята, доступ к боту разрешен!\nhttps://telegra.ph/Rebot-Guide-09-17',
            reply_markup=keyboard.main_key)
    except Exception as ex:
        bot.send_message(config.settings['service_chat'],
                         'Не удалось добавить пользователя' + str(ex))
示例#3
0
def signup(text=''):
    if current_user.is_authenticated:
        return redirect('dashboard')
    if request.method == 'POST':
        username = request.form.get('username')
        if not alphanum(username):
            return render_template('signup.html',
                                   text="Username must be alphanumeric")
        password = request.form.get('password')
        text = add_user(username, password)
        if text == 'Signed up successfully!':
            user = find_user(username, password)
            if user is not None:
                login_user(User(username),
                           remember=request.form.get('remember_me'))
                session['username'] = username
                return redirect('dashboard')
    return render_template('signup.html', text=text)
 def test_find_user(self):
     username = str(random.randint(1,10000000000000))
     password = '******'
     add_user(username,password)
     self.assertTrue(find_user(username,password))
 def test_add_same_user(self):
     username = str(random.randint(1,10000000000000))
     password = '******'
     add_user(username, password)
     self.assertEqual('Username already in use.',
     add_user(username, password))
 def test_add_new_user(self):
     username = str(random.randint(1,10000000000000))
     password = '******'
     self.assertEqual('Signed up successfully!', add_user(username,password))