-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mane Motha
committed
Jun 2, 2022
1 parent
2031496
commit 6d72698
Showing
5 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ | |
import json | ||
import sys | ||
import os | ||
|
||
from logic import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .account import * | ||
from .variables import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import websockets | ||
import asyncio | ||
import bcrypt | ||
import datetime | ||
import sys | ||
import os | ||
import json | ||
import sqlite3 | ||
|
||
# modules | ||
from logic import * | ||
from logic.variables import * | ||
from .account import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import json | ||
import sqlite3 | ||
|
||
from .__init__ import * | ||
|
||
|
||
class Account: | ||
|
||
def __init__(self, json_packet: dict): | ||
self.user_account = json_packet | ||
self.user_profile = json_packet['profile'] | ||
self.email: str = self.user_account['email'] | ||
self.username: str = self.user_account['username'] | ||
self.password: str = self.user_account['password'] | ||
|
||
async def signup(self): | ||
try: | ||
if not os.path.exists(database_directory): | ||
os.makedirs(database_directory) | ||
|
||
# create and open database file | ||
database = sqlite3.connect(f'{database_directory}/accounts.db') | ||
cursor = database.cursor() | ||
|
||
# create user table from username | ||
cursor.execute(f""" | ||
CREATE TABLE {self.username} (account json) """) | ||
|
||
# add values | ||
cursor.execute(f"insert into {self.username} values (?)", [json.dumps(self.user_account)]) | ||
database.commit() | ||
return {"result": account_generated_true} | ||
|
||
except sqlite3.OperationalError: | ||
return {"result": account_exists_true} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters