From 3b9ce27b939af57f3435eb945ddac8259e795aa2 Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 9 Aug 2021 18:45:51 +0300 Subject: [PATCH] origin --- README.md | 2 +- resolvers/__init__.py | 7 ++++--- resolvers/auth.py | 6 +++--- schema.graphql | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2b377785..63b6ad51 100644 --- a/README.md +++ b/README.md @@ -33,4 +33,4 @@ Also see `Dockerfile` # How to do an authorized request -Put the header 'Auth' with token from signInQuery in requests. \ No newline at end of file +Put the header 'Auth' with token from signInQuery or registerQuery. \ No newline at end of file diff --git a/resolvers/__init__.py b/resolvers/__init__.py index c3d304fc..b9a70416 100644 --- a/resolvers/__init__.py +++ b/resolvers/__init__.py @@ -1,11 +1,12 @@ -from resolvers.auth import sign_in, sign_out, register, confirm +from resolvers.auth import login, sign_out, get_user, is_email_free, register, confirm from resolvers.inbox import create_message, delete_message, update_message, get_messages from resolvers.zine import create_shout __all__ = [ - "sign_in", - "sign_out", + "login", "register", + "get_user", + "is_email_free", "confirm", # TODO: "reset_password_code", # TODO: "reset_password_confirm", diff --git a/resolvers/auth.py b/resolvers/auth.py index 18b444a7..435e07db 100644 --- a/resolvers/auth.py +++ b/resolvers/auth.py @@ -43,7 +43,7 @@ async def register(*_, email: str, password: str = ""): @query.field("signIn") -async def sign_in(_, info: GraphQLResolveInfo, email: str, password: str): +async def login(_, info: GraphQLResolveInfo, email: str, password: str): with local_session() as session: orm_user = session.query(User).filter(User.email == email).first() if orm_user is None: @@ -61,7 +61,7 @@ async def sign_in(_, info: GraphQLResolveInfo, email: str, password: str): return {"error" : "invalid password"} token = await Authorize.authorize(user, device=device, auto_delete=auto_delete) - return {"token" : token, "user": user} + return {"token" : token, "user": user}} @query.field("signOut") @@ -69,7 +69,7 @@ async def sign_in(_, info: GraphQLResolveInfo, email: str, password: str): async def sign_out(_, info: GraphQLResolveInfo): token = info.context["request"].headers[JWT_AUTH_HEADER] status = await Authorize.revoke(token) - return {} + return True @query.field("getCurrentUser") @login_required diff --git a/schema.graphql b/schema.graphql index 45ff9da6..84539235 100644 --- a/schema.graphql +++ b/schema.graphql @@ -69,8 +69,8 @@ type Mutation { rateShout(slug: String!, value: Int!): Result! # user profile - # rateUser(value: Int!): ResultPayload! - # updateOnlineStatus: ResultPayload! + # rateUser(value: Int!): Result! + # updateOnlineStatus: Result! updateProfile(profile: ProfileInput!): Result! }