Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
from Frequency import FrequencyType
from tinydb.queries import Query
from Content import ContentType
from Subscription import Subscription
from db import DB
class User:
"""
Represents a user of the application.
"""
def __init__(self) -> None:
self.userTable = DB().db.table('User')
def createUser(self, username, email):
if self.userTable.get(Query().username == username):
raise Exception("username has been taken")
self.userTable.insert({
'username': username,
'email': email
})
def getUserByUsername(self, username):
return self.userTable.search(Query()['username'] == username)
def validateUser(self, username):
UserQuery = Query()
if self.userTable.search(UserQuery['username'] == username):
return True
return False