fix-scheme
This commit is contained in:
parent
9052872c87
commit
5bf3621724
|
@ -1,24 +1,27 @@
|
||||||
from jwt import DecodeError, ExpiredSignatureError
|
from jwt import DecodeError, ExpiredSignatureError
|
||||||
|
from passlib.hash import bcrypt
|
||||||
from sqlalchemy import or_
|
from sqlalchemy import or_
|
||||||
|
|
||||||
from auth.jwtcodec import JWTCodec
|
from auth.jwtcodec import JWTCodec
|
||||||
from auth.tokenstorage import TokenStorage
|
from auth.tokenstorage import TokenStorage
|
||||||
from validations.auth import AuthInput
|
from base.exceptions import InvalidPassword, InvalidToken
|
||||||
from base.exceptions import InvalidPassword
|
|
||||||
from base.exceptions import InvalidToken
|
|
||||||
from base.orm import local_session
|
from base.orm import local_session
|
||||||
from orm import User
|
from orm import User
|
||||||
from passlib.hash import bcrypt
|
from validations.auth import AuthInput
|
||||||
|
|
||||||
|
|
||||||
class Password:
|
class Password:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def encode(password: str) -> str:
|
def encode(password: str) -> str:
|
||||||
|
|
||||||
|
# TODO: sha256 -> hexdigest -> bcrypt
|
||||||
return bcrypt.hash(password)
|
return bcrypt.hash(password)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def verify(password: str, other: str) -> bool:
|
def verify(password: str, hashed: str) -> bool:
|
||||||
return bcrypt.verify(password, other)
|
# TODO: detect rounds amount
|
||||||
|
# TODO: sha256 -> hexdigest -> bcrypt
|
||||||
|
return bcrypt.verify(password, hashed)
|
||||||
|
|
||||||
|
|
||||||
class Identity:
|
class Identity:
|
||||||
|
|
|
@ -3,7 +3,7 @@ from sqlalchemy.exc import IntegrityError
|
||||||
|
|
||||||
from base.orm import local_session
|
from base.orm import local_session
|
||||||
from migration.html2text import html2text
|
from migration.html2text import html2text
|
||||||
from orm.user import User, UserRating, AuthorFollower
|
from orm.user import AuthorFollower, User, UserRating
|
||||||
|
|
||||||
|
|
||||||
def migrate(entry):
|
def migrate(entry):
|
||||||
|
@ -16,7 +16,6 @@ def migrate(entry):
|
||||||
"ratings": [],
|
"ratings": [],
|
||||||
"username": email,
|
"username": email,
|
||||||
"email": email,
|
"email": email,
|
||||||
"password": entry["services"]["password"].get("bcrypt", ""),
|
|
||||||
"createdAt": parse(entry["createdAt"]),
|
"createdAt": parse(entry["createdAt"]),
|
||||||
"emailConfirmed": bool(entry["emails"][0]["verified"]),
|
"emailConfirmed": bool(entry["emails"][0]["verified"]),
|
||||||
"muted": False, # amnesty
|
"muted": False, # amnesty
|
||||||
|
@ -25,6 +24,7 @@ def migrate(entry):
|
||||||
"links": [],
|
"links": [],
|
||||||
"name": "anonymous",
|
"name": "anonymous",
|
||||||
}
|
}
|
||||||
|
user_dict["password"] = entry["services"]["password"].get("bcrypt")
|
||||||
if "updatedAt" in entry:
|
if "updatedAt" in entry:
|
||||||
user_dict["updatedAt"] = parse(entry["updatedAt"])
|
user_dict["updatedAt"] = parse(entry["updatedAt"])
|
||||||
if "wasOnineAt" in entry:
|
if "wasOnineAt" in entry:
|
||||||
|
|
|
@ -107,7 +107,7 @@ async def create_chat(_, info, title="", members=[]):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def load_messages(chatId: int, offset: int, amount: int):
|
async def load_messages(chatId: str, offset: int, amount: int):
|
||||||
messages = []
|
messages = []
|
||||||
message_ids = await redis.lrange(
|
message_ids = await redis.lrange(
|
||||||
f"chats/{chatId}/message_ids", 0 - offset - amount, 0 - offset
|
f"chats/{chatId}/message_ids", 0 - offset - amount, 0 - offset
|
||||||
|
|
|
@ -197,8 +197,8 @@ type Mutation {
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
# inbox
|
# inbox
|
||||||
myChats: [Chat]!
|
myChats: Result!
|
||||||
loadChat(chatId: String!, offset: Int, amount: Int): [Message]!
|
loadChat(chatId: String!, offset: Int, amount: Int): Result!
|
||||||
|
|
||||||
# auth
|
# auth
|
||||||
isEmailUsed(email: String!): Boolean!
|
isEmailUsed(email: String!): Boolean!
|
||||||
|
@ -487,7 +487,7 @@ type Message {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Chat {
|
type Chat {
|
||||||
id: Int!
|
id: String!
|
||||||
createdAt: Int!
|
createdAt: Int!
|
||||||
createdBy: User!
|
createdBy: User!
|
||||||
updatedAt: Int!
|
updatedAt: Int!
|
||||||
|
|
Loading…
Reference in New Issue
Block a user