Compare commits

..

No commits in common. "ab92ecfb4af57c7da9ec4514c74b9a7a15e86a60" and "6d4717e4711536e4dd3140ba13d4cc67e81577df" have entirely different histories.

3 changed files with 14 additions and 8 deletions

4
.gitignore vendored
View file

@ -160,5 +160,5 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
config/*
db/*
config
db

View file

@ -40,13 +40,13 @@ class Cert():
def register(self, username, userid):
cursor = self.db.cursor()
insert_sql = "INSERT INTO user_list (discord_username, discord_userid) VALUES (?, ?);"
insert_sql = "INSERT INTO user_list (discord_username, discord_userid) VALUES (%s, %s);"
cursor.execute(insert_sql, (username, userid))
self.db.commit()
def get_username(self, username, password):
cursor = self.db.cursor()
get_sql = "SELECT * FROM web_auth WHERE username = ? AND password = ? "
get_sql = "SELECT * FROM web_auth WHERE username = %s AND password = %s "
cursor.execute(get_sql, (username, password))
result = cursor.fetchall()
print(result)
@ -55,8 +55,14 @@ class Cert():
elif result[0][1] == username and result[0][2] == password:
return 0
class Web(flask.Flask):
async def temp(self):
print("")
cert = Cert()
print(cert.get_username("suti7", "0126"))
bot_config_path = "./config/bot.json"
if not os.path.isfile(bot_config_path):

View file

@ -1,6 +1,6 @@
from flask import Flask, request, render_template, redirect, url_for
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user
import sqlite3
import psycopg2
app = Flask(__name__, static_folder="./resource/")
app.secret_key = 'your_secret_key'
@ -9,17 +9,17 @@ login_manager.init_app(app)
class Cert():
def __init__(self):
self.db = sqlite3.connect("host=localhost dbname=dislocker user=suti7 password=testing")
self.db = psycopg2.connect("host=localhost dbname=dislocker user=suti7 password=testing")
def register(self, username, userid):
cursor = self.db.cursor()
insert_sql = "INSERT INTO user_list (discord_username, discord_userid) VALUES (?, ?)"
insert_sql = "INSERT INTO user_list (discord_username, discord_userid) VALUES (%s, %s);"
cursor.execute(insert_sql, (username, userid))
self.db.commit()
def login(self, username, password):
cursor = self.db.cursor()
get_sql = "SELECT * FROM web_auth WHERE username = ? AND password = ? "
get_sql = "SELECT * FROM web_auth WHERE username = %s AND password = %s "
cursor.execute(get_sql, (username, password))
result = cursor.fetchall()
print(result)