feat(auth): add user and role management

This commit is contained in:
Ali BARIN
2023-07-18 21:00:10 +00:00
parent a7104c41a2
commit 0deaa03218
108 changed files with 2909 additions and 388 deletions

View File

@@ -0,0 +1,12 @@
import { gql } from '@apollo/client';
export const CREATE_ROLE = gql`
mutation CreateRole($input: CreateRoleInput) {
createRole(input: $input) {
id
key
name
description
}
}
`;

View File

@@ -3,8 +3,12 @@ import { gql } from '@apollo/client';
export const CREATE_USER = gql`
mutation CreateUser($input: CreateUserInput) {
createUser(input: $input) {
id
email
fullName
role {
id
}
}
}
`;

View File

@@ -0,0 +1,7 @@
import { gql } from '@apollo/client';
export const DELETE_CURRENT_USER = gql`
mutation DeleteCurrentUser {
deleteCurrentUser
}
`;

View File

@@ -0,0 +1,7 @@
import { gql } from '@apollo/client';
export const DELETE_ROLE = gql`
mutation DeleteRole($input: DeleteRoleInput) {
deleteRole(input: $input)
}
`;

View File

@@ -1,7 +1,7 @@
import { gql } from '@apollo/client';
export const DELETE_USER = gql`
mutation DeleteUser {
deleteUser
mutation DeleteUser($input: DeleteUserInput) {
deleteUser(input: $input)
}
`;

View File

@@ -0,0 +1,11 @@
import { gql } from '@apollo/client';
export const REGISTER_USER = gql`
mutation RegisterUser($input: RegisterUserInput) {
registerUser(input: $input) {
id
email
fullName
}
}
`;

View File

@@ -0,0 +1,11 @@
import { gql } from '@apollo/client';
export const UPDATE_CURRENT_USER = gql`
mutation UpdateCurrentUser($input: UpdateCurrentUserInput) {
updateCurrentUser(input: $input) {
id
fullName
email
}
}
`;

View File

@@ -0,0 +1,17 @@
import { gql } from '@apollo/client';
export const UPDATE_ROLE = gql`
mutation UpdateRole($input: UpdateRoleInput) {
updateRole(input: $input) {
id
name
description
permissions {
id
action
subject
conditions
}
}
}
`;

View File

@@ -4,8 +4,8 @@ export const UPDATE_USER = gql`
mutation UpdateUser($input: UpdateUserInput) {
updateUser(input: $input) {
id
fullName
email
fullName
}
}
`;

View File

@@ -6,6 +6,16 @@ export const GET_CURRENT_USER = gql`
id
fullName
email
role {
id
isAdmin
}
permissions {
id
action
subject
conditions
}
}
}
`;

View File

@@ -0,0 +1,21 @@
import { gql } from '@apollo/client';
export const GET_PERMISSION_CATALOG = gql`
query GetPermissionCatalog {
getPermissionCatalog {
subjects {
key
label
}
conditions {
key
label
}
actions {
label
key
subjects
}
}
}
`;

View File

@@ -0,0 +1,19 @@
import { gql } from '@apollo/client';
export const GET_ROLE = gql`
query GetRole($id: String!) {
getRole(id: $id) {
id
key
name
description
isAdmin
permissions {
id
action
subject
conditions
}
}
}
`;

View File

@@ -0,0 +1,13 @@
import { gql } from '@apollo/client';
export const GET_ROLES = gql`
query GetRoles {
getRoles {
id
key
name
description
isAdmin
}
}
`;

View File

@@ -0,0 +1,19 @@
import { gql } from '@apollo/client';
export const GET_USER = gql`
query GetUser($id: String!) {
getUser(id: $id) {
id
fullName
email
role {
id
key
name
isAdmin
}
createdAt
updatedAt
}
}
`;

View File

@@ -0,0 +1,29 @@
import { gql } from '@apollo/client';
export const GET_USERS = gql`
query GetUsers(
$limit: Int!
$offset: Int!
) {
getUsers(
limit: $limit
offset: $offset
) {
pageInfo {
currentPage
totalPages
}
edges {
node {
id
fullName
email
role {
id
name
}
}
}
}
}
`;