authfixes
This commit is contained in:
parent
f13f40c89a
commit
0873304068
|
@ -1,3 +1,4 @@
|
||||||
|
from datetime import datetime
|
||||||
from orm.user import User, UserRole, Role, UserRating, AuthorFollower
|
from orm.user import User, UserRole, Role, UserRating, AuthorFollower
|
||||||
from services.auth.users import UserStorage
|
from services.auth.users import UserStorage
|
||||||
from orm.shout import Shout
|
from orm.shout import Shout
|
||||||
|
@ -59,7 +60,7 @@ async def user_followers(_, slug) -> List[User]:
|
||||||
all()
|
all()
|
||||||
return users
|
return users
|
||||||
|
|
||||||
# for query.field("getCurrentUser")
|
# for query.field("refreshSession")
|
||||||
async def get_user_info(slug):
|
async def get_user_info(slug):
|
||||||
return {
|
return {
|
||||||
"inbox": await get_inbox_counter(slug),
|
"inbox": await get_inbox_counter(slug),
|
||||||
|
@ -70,10 +71,14 @@ async def get_user_info(slug):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@query.field("getCurrentUser")
|
@query.field("refreshSession")
|
||||||
@login_required
|
@login_required
|
||||||
async def get_current_user(_, info):
|
async def get_current_user(_, info):
|
||||||
user = info.context["request"].user
|
user = info.context["request"].user
|
||||||
|
with local_session() as session:
|
||||||
|
user.lastSeen = datetime.now()
|
||||||
|
user.save()
|
||||||
|
session.commit()
|
||||||
return {
|
return {
|
||||||
"user": user,
|
"user": user,
|
||||||
"info": await get_user_info(user.slug)
|
"info": await get_user_info(user.slug)
|
||||||
|
|
|
@ -140,10 +140,10 @@ type Mutation {
|
||||||
|
|
||||||
# auth
|
# auth
|
||||||
confirmEmail(token: String!): AuthResult!
|
confirmEmail(token: String!): AuthResult!
|
||||||
|
refreshSession: AuthResult!
|
||||||
registerUser(email: String!, password: String): AuthResult!
|
registerUser(email: String!, password: String): AuthResult!
|
||||||
requestPasswordUpdate(email: String!): Result!
|
requestPasswordUpdate(email: String!): Result!
|
||||||
updatePassword(password: String!, token: String!): Result!
|
updatePassword(password: String!, token: String!): Result!
|
||||||
# requestEmailConfirmation: User!
|
|
||||||
|
|
||||||
# shout
|
# shout
|
||||||
createShout(input: ShoutInput!): Result!
|
createShout(input: ShoutInput!): Result!
|
||||||
|
@ -203,10 +203,6 @@ type Query {
|
||||||
isEmailUsed(email: String!): Boolean!
|
isEmailUsed(email: String!): Boolean!
|
||||||
signIn(email: String!, password: String): AuthResult!
|
signIn(email: String!, password: String): AuthResult!
|
||||||
signOut: AuthResult!
|
signOut: AuthResult!
|
||||||
forget(email: String!): AuthResult!
|
|
||||||
requestPasswordReset(email: String!): AuthResult!
|
|
||||||
updatePassword(password: String!, token: String!): AuthResult!
|
|
||||||
getCurrentUser: AuthResult!
|
|
||||||
|
|
||||||
# profile
|
# profile
|
||||||
getUsersBySlugs(slugs: [String]!): [User]!
|
getUsersBySlugs(slugs: [String]!): [User]!
|
||||||
|
@ -312,6 +308,7 @@ type User {
|
||||||
id: Int!
|
id: Int!
|
||||||
username: String! # to login, ex. email
|
username: String! # to login, ex. email
|
||||||
createdAt: DateTime!
|
createdAt: DateTime!
|
||||||
|
lastSeen: DataTime
|
||||||
slug: String!
|
slug: String!
|
||||||
name: String # to display
|
name: String # to display
|
||||||
email: String
|
email: String
|
||||||
|
|
Loading…
Reference in New Issue
Block a user