fdfd
This commit is contained in:
parent
f86ca388e8
commit
a576b3cd04
5 changed files with 16 additions and 60 deletions
|
@ -7,29 +7,22 @@ from .submission import Submission
|
|||
from .comment import Comment
|
||||
from drama.__main__ import Base
|
||||
|
||||
|
||||
class OauthApp(Base, Stndrd):
|
||||
|
||||
__tablename__ = "oauth_apps"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
client_id = Column(String(64))
|
||||
client_secret = Column(String(128))
|
||||
app_name = Column(String(50))
|
||||
redirect_uri = Column(String(4096))
|
||||
author_id = Column(Integer, ForeignKey("users.id"))
|
||||
is_banned = Column(Boolean, default=False)
|
||||
description = Column(String(256))
|
||||
|
||||
author = relationship("User")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<OauthApp(id={self.id})>"
|
||||
def __repr__(self): return f"<OauthApp(id={self.id})>"
|
||||
|
||||
@property
|
||||
def permalink(self):
|
||||
def permalink(self): return f"/admin/app/{self.id}"
|
||||
|
||||
return f"/admin/app/{self.id}"
|
||||
|
||||
def idlist(self, page=1, **kwargs):
|
||||
|
||||
|
@ -51,41 +44,12 @@ class OauthApp(Base, Stndrd):
|
|||
|
||||
return [x[0] for x in posts.all()]
|
||||
|
||||
|
||||
|
||||
|
||||
class ClientAuth(Base, Stndrd):
|
||||
|
||||
__tablename__ = "client_auths"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
oauth_client = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||
oauth_code = Column(String(128))
|
||||
user_id = Column(Integer, ForeignKey("users.id"))
|
||||
scope_identity = Column(Boolean, default=False)
|
||||
scope_create = Column(Boolean, default=False)
|
||||
scope_read = Column(Boolean, default=False)
|
||||
scope_update = Column(Boolean, default=False)
|
||||
scope_delete = Column(Boolean, default=False)
|
||||
scope_vote = Column(Boolean, default=False)
|
||||
access_token = Column(String(128))
|
||||
refresh_token = Column(String(128))
|
||||
access_token_expire_utc = Column(Integer)
|
||||
|
||||
user = relationship("User", lazy="joined")
|
||||
application = relationship("OauthApp", lazy="joined")
|
||||
|
||||
@property
|
||||
def scopelist(self):
|
||||
|
||||
output = ""
|
||||
output += "identity," if self.scope_identity else ""
|
||||
output += "create," if self.scope_create else ""
|
||||
output += "read," if self.scope_read else ""
|
||||
output += "update," if self.scope_update else ""
|
||||
output += "delete," if self.scope_delete else ""
|
||||
output += "vote," if self.scope_vote else ""
|
||||
|
||||
output = output.rstrip(',')
|
||||
|
||||
return output
|
||||
application = relationship("OauthApp", lazy="joined")
|
Loading…
Add table
Add a link
Reference in a new issue