remove unneeded files
This commit is contained in:
commit
4f2f4187fe
|
@ -1,46 +0,0 @@
|
|||
import jwt
|
||||
from hashlib import md5
|
||||
|
||||
# see: settings.py
|
||||
JWT_SECRET_KEY = "my secret key"
|
||||
JWT_ALGORITHM = "HS256"
|
||||
|
||||
JWT_AUTH_HEADER = "HTTP_AUTHORIZATION"
|
||||
|
||||
|
||||
# see: auth.password.Password
|
||||
def password_to_hash(password):
|
||||
return md5(password.encode('utf-8')).hexdigest()
|
||||
|
||||
def verify_password(password, hash):
|
||||
return password_to_hash(password) == hash
|
||||
|
||||
# see: auth.auth.token.Token
|
||||
def jwt_encode(user):
|
||||
payload = {
|
||||
"user_id" : user.id
|
||||
}
|
||||
|
||||
token = jwt.encode(payload, JWT_SECRET_KEY, JWT_ALGORITHM)
|
||||
|
||||
if isinstance(token, bytes):
|
||||
return token.decode('utf-8')
|
||||
|
||||
return token
|
||||
|
||||
def jwt_decode(token):
|
||||
try:
|
||||
payload = jwt.decode(token, JWT_SECRET_KEY, algorithms = [JWT_ALGORITHM])
|
||||
except jwt.DecodeError:
|
||||
raise Exception("Error decoding signature")
|
||||
except jwt.InvalidTokenError:
|
||||
raise Exception("Invalid token")
|
||||
|
||||
user_id = payload["user_id"]
|
||||
return user_id
|
||||
|
||||
# see: auth.authorize
|
||||
def authorize(request):
|
||||
token = request.headers.get(JWT_AUTH_HEADER, '')
|
||||
user_id = jwt_decode(token)
|
||||
return user_id
|
163
schema.graphql
163
schema.graphql
|
@ -1,163 +0,0 @@
|
|||
scalar DateTime
|
||||
|
||||
type createMessagePayload {
|
||||
status: Boolean!
|
||||
error: String
|
||||
message: Message
|
||||
}
|
||||
|
||||
type deleteMessagePayload {
|
||||
status: Boolean!
|
||||
error: String
|
||||
}
|
||||
|
||||
input MessageInput {
|
||||
body: String!
|
||||
replyTo: Int
|
||||
}
|
||||
|
||||
input updateMessageInput {
|
||||
id: Int!
|
||||
body: String!
|
||||
}
|
||||
|
||||
type Message {
|
||||
author: Int!
|
||||
visibleForUsers: [Int]
|
||||
body: String!
|
||||
createdAt: DateTime!
|
||||
id: Int!
|
||||
replyTo: Int
|
||||
updatedAt: DateTime!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
# message
|
||||
createMessage(input: MessageInput!): createMessagePayload!
|
||||
updateMessage(input: updateMessageInput!): createMessagePayload!
|
||||
deleteMessage(messageId: Int!): deleteMessagePayload!
|
||||
|
||||
# auth
|
||||
confirmEmail(token: String!): Token!
|
||||
invalidateAllTokens: Boolean!
|
||||
invalidateTokenById(id: Int!): Boolean!
|
||||
requestEmailConfirmation: User!
|
||||
requestPasswordReset(email: String!): Boolean!
|
||||
resetPassword(password: String!, token: String!): Token!
|
||||
signIn(email: String!, password: String!): Token! # login
|
||||
signUp(email: String!, password: String!, username: String): User! # register
|
||||
|
||||
# shout
|
||||
createShout(body: String!, replyTo: [Int], title: String, versionOf: [Int], visibleForRoles: [Int], visibleForUsers: [Int]): Message!
|
||||
deleteShout(shoutId: Int!): Message!
|
||||
rateShout(value: Int!): Boolean!
|
||||
|
||||
# profile
|
||||
rateUser(value: Int!): Boolean!
|
||||
updateOnlineStatus: Boolean!
|
||||
updateUsername(username: String!): User!
|
||||
|
||||
# proposal
|
||||
createProposal(shout: Int!, range: String!): Boolean!
|
||||
updateProposal(proposal: Int!, body: String!): Boolean!
|
||||
removeProposal(proposal: Int!): Boolean!
|
||||
approveProposal(proposal: Int!): Boolean!
|
||||
}
|
||||
|
||||
type Query {
|
||||
# auth
|
||||
getCurrentUser: User!
|
||||
logout: [Boolean!]
|
||||
getTokens: [Token!]!
|
||||
isUsernameFree(username: String!): Boolean!
|
||||
|
||||
# profile
|
||||
getUserById(id: Int!): User!
|
||||
getUserRating(shout: Int): Int!
|
||||
getOnline: [User!]!
|
||||
|
||||
# message
|
||||
getMessages(count: Int = 100, page: Int = 1): [Message!]!
|
||||
|
||||
# shout
|
||||
getShoutRating(shout: Int): Int!
|
||||
shoutsByAuthor(author: Int): [Shout]!
|
||||
shoutsByReplyTo(shout: Int): [Shout]!
|
||||
shoutsByTags(tags: [String]): [Shout]!
|
||||
shoutsByTime(time: DateTime): [Shout]!
|
||||
topAuthors: [User]!
|
||||
topShouts: [Shout]!
|
||||
|
||||
# proposal
|
||||
getShoutProposals(shout: Int): [Proposal]!
|
||||
}
|
||||
|
||||
type Role {
|
||||
id: Int!
|
||||
name: String!
|
||||
}
|
||||
|
||||
type Shout {
|
||||
author: Int!
|
||||
body: String!
|
||||
createdAt: DateTime!
|
||||
deletedAt: DateTime
|
||||
deletedBy: Int
|
||||
id: Int!
|
||||
rating: Int
|
||||
published: DateTime! # if there is no published field - it is not published
|
||||
replyTo: Int # another shout
|
||||
tags: [String]
|
||||
title: String
|
||||
updatedAt: DateTime!
|
||||
versionOf: Int
|
||||
visibleForRoles: [Role]!
|
||||
visibleForUsers: [Int]
|
||||
}
|
||||
|
||||
type Proposal {
|
||||
body: String!
|
||||
shout: Int!
|
||||
range: String # full / 0:2340
|
||||
author: Int!
|
||||
createdAt: DateTime!
|
||||
}
|
||||
|
||||
type Subscription {
|
||||
profileUpdate(user_id: Int!): User!
|
||||
chatUpdate(user_id: Int!): Message!
|
||||
onlineUpdate: [User!]! # userlist
|
||||
shoutUpdate(shout_id: Int!): Shout!
|
||||
}
|
||||
|
||||
type Token {
|
||||
createdAt: DateTime!
|
||||
expiresAt: DateTime
|
||||
id: Int!
|
||||
ownerId: Int!
|
||||
usedAt: DateTime
|
||||
value: String!
|
||||
}
|
||||
|
||||
type User {
|
||||
createdAt: DateTime!
|
||||
email: String
|
||||
emailConfirmed: Boolean
|
||||
id: Int!
|
||||
muted: Boolean
|
||||
rating: Int
|
||||
roles: [Role!]!
|
||||
updatedAt: DateTime!
|
||||
username: String
|
||||
userpic: String
|
||||
userpicId: String
|
||||
wasOnlineAt: DateTime
|
||||
}
|
||||
|
||||
type Like {
|
||||
author: Int!
|
||||
id: Int!
|
||||
shout: Int
|
||||
user: Int
|
||||
value: Int!
|
||||
}
|
Loading…
Reference in New Issue
Block a user