Removed uncessary GraphQL files | Added README to auth service
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
# Auth Service
|
||||
This service handles user authentication and authorization using Ory Kratos and integrates with a REST API.
|
||||
|
||||
## Technologies Used
|
||||
- **Ory Kratos (self-hosted)**: Identity and user management system.
|
||||
- **Express.js**: Web framework for building the REST API.
|
||||
- **PostgreSQL**: Database for storing user data.
|
||||
- **Docker**: Kratos, PostgreSQL, and this service are containerized for easy deployment.
|
||||
|
||||
Kratos was chosen for its robust identity management capabilities, including support for multiple authentication methods and self-service flows. It also provides first class support for PostgreSQL, which was my preferred database choice for this project.
|
||||
@@ -1,26 +0,0 @@
|
||||
|
||||
type userLoginInput = {
|
||||
email: String!
|
||||
password: String!
|
||||
}
|
||||
|
||||
|
||||
const resolvers = {
|
||||
Mutation: {
|
||||
login: async (_parent, { input: input }, context) => {
|
||||
const { email, password } = input;
|
||||
// Db connection and authentication logic here
|
||||
const user = await context.db.users.findOne({ email });
|
||||
if (!user || user.password !== password || !user.email) {
|
||||
return { userLoginSuccessStatus: false };
|
||||
else if (user && user.password === password && user.email) {
|
||||
return { userLoginSuccessStatus: true };
|
||||
}
|
||||
else {
|
||||
return { userLoginSuccessStatus: false };
|
||||
console.log("User not found or unknown error");
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
input UserLoginInput {
|
||||
email: String!
|
||||
password: String!
|
||||
}
|
||||
|
||||
type User {
|
||||
id: ID!
|
||||
firstName: String!
|
||||
lastName: String!
|
||||
email: String!
|
||||
dateOfBirth: String!
|
||||
}
|
||||
|
||||
type UserLoginResponse {
|
||||
success: Boolean!
|
||||
token: String
|
||||
user: User
|
||||
error: String
|
||||
}
|
||||
|
||||
input CreateUserInput {
|
||||
firstName: String!
|
||||
lastName: String!
|
||||
email: String!
|
||||
password: String!
|
||||
dateOfBirth: String!
|
||||
}
|
||||
|
||||
type CreateUserResponse {
|
||||
success: Boolean!
|
||||
token: String
|
||||
user: User
|
||||
error: String
|
||||
}
|
||||
|
||||
type UserLogoutResponse {
|
||||
success: Boolean!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
login(input: UserLoginInput!): UserLoginResponse!
|
||||
logout: UserLogoutResponse!
|
||||
createUser(input: CreateUserInput!): CreateUserResponse!
|
||||
}
|
||||
Reference in New Issue
Block a user