Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
repp_backend
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julieta Dubra Raimunde
repp_backend
Commits
6209a4c3
Commit
6209a4c3
authored
3 years ago
by
Renzo Beux
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/develop' into feature/Audit
parents
acde1bea
efd91337
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.env
+2
-2
2 additions, 2 deletions
.env
src/Controllers/UserController.ts
+14
-7
14 additions, 7 deletions
src/Controllers/UserController.ts
src/Services/UserAPI.ts
+29
-48
29 additions, 48 deletions
src/Services/UserAPI.ts
with
45 additions
and
57 deletions
.env
+
2
−
2
View file @
6209a4c3
...
...
@@ -3,5 +3,5 @@ INSTANCE=TEST
HOST=localhost
USER=developer
PASSWORD=password
DB=core_database_test
AUTH_BASE_URL=http://localhost:4000/users
\ No newline at end of file
DB=parameter_database
AUTH_BASE_URL=http://localhost:3000/users
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Controllers/UserController.ts
+
14
−
7
View file @
6209a4c3
...
...
@@ -20,7 +20,8 @@ const create: Handler = async (req: Request, res: Response) => {
const
listUsers
:
Handler
=
async
(
req
:
Request
,
res
:
Response
)
=>
{
try
{
const
userList
:
any
=
await
UserAPI
.
listUsers
(
req
.
body
);
const
token
:
any
=
req
.
headers
.
authorization
;
const
userList
:
any
=
await
UserAPI
.
listUsers
(
req
.
query
.
type
,
token
);
return
res
.
status
(
200
).
send
(
userList
);
}
catch
(
error
)
{
const
e
=
error
as
Error
;
...
...
@@ -40,7 +41,8 @@ const login: Handler = async (req: Request, res: Response) => {
const
update
:
Handler
=
async
(
req
:
Request
,
res
:
Response
)
=>
{
try
{
const
user
:
any
=
await
UserAPI
.
update
(
req
.
body
,
req
.
params
.
id
);
const
token
:
any
=
req
.
headers
.
authorization
;
const
user
:
any
=
await
UserAPI
.
update
(
req
.
body
,
req
.
params
.
id
,
token
);
return
res
.
status
(
200
).
send
(
user
);
}
catch
(
error
)
{
const
e
=
error
as
Error
;
...
...
@@ -50,7 +52,8 @@ const update: Handler = async (req: Request, res: Response) => {
const
password
:
Handler
=
async
(
req
:
Request
,
res
:
Response
)
=>
{
try
{
const
user
:
any
=
await
UserAPI
.
password
(
req
.
body
,
req
.
params
.
id
);
const
token
:
any
=
req
.
headers
.
authorization
;
const
user
:
any
=
await
UserAPI
.
password
(
req
.
body
,
req
.
params
.
id
,
token
);
return
res
.
status
(
200
).
send
(
user
);
}
catch
(
error
)
{
const
e
=
error
as
Error
;
...
...
@@ -60,7 +63,8 @@ const password: Handler = async (req: Request, res: Response) => {
const
approve
:
Handler
=
async
(
req
:
Request
,
res
:
Response
)
=>
{
try
{
const
user
:
any
=
await
UserAPI
.
approve
(
req
.
params
.
id
);
const
token
:
any
=
req
.
headers
.
authorization
;
const
user
:
any
=
await
UserAPI
.
approve
(
req
.
params
.
id
,
token
);
return
res
.
status
(
200
).
send
(
user
);
}
catch
(
error
)
{
const
e
=
error
as
Error
;
...
...
@@ -70,7 +74,8 @@ const approve: Handler = async (req: Request, res: Response) => {
const
cancel
:
Handler
=
async
(
req
:
Request
,
res
:
Response
)
=>
{
try
{
const
user
:
any
=
await
UserAPI
.
cancel
(
req
.
params
.
id
);
const
token
:
any
=
req
.
headers
.
authorization
;
const
user
:
any
=
await
UserAPI
.
cancel
(
req
.
params
.
id
,
token
);
return
res
.
status
(
200
).
send
(
user
);
}
catch
(
error
)
{
const
e
=
error
as
Error
;
...
...
@@ -80,7 +85,8 @@ const cancel: Handler = async (req: Request, res: Response) => {
const
giveAdminPermission
:
Handler
=
async
(
req
:
Request
,
res
:
Response
)
=>
{
try
{
const
user
:
any
=
await
UserAPI
.
giveAdminPermission
(
req
.
params
.
id
);
const
token
:
any
=
req
.
headers
.
authorization
;
const
user
:
any
=
await
UserAPI
.
giveAdminPermission
(
req
.
params
.
id
,
token
);
return
res
.
status
(
200
).
send
(
user
);
}
catch
(
error
)
{
const
e
=
error
as
Error
;
...
...
@@ -90,7 +96,8 @@ const giveAdminPermission: Handler = async (req: Request, res: Response) => {
const
removeAdminPermission
:
Handler
=
async
(
req
:
Request
,
res
:
Response
)
=>
{
try
{
const
user
:
any
=
await
UserAPI
.
removeAdminPermission
(
req
.
params
.
id
);
const
token
:
any
=
req
.
headers
.
authorization
;
const
user
:
any
=
await
UserAPI
.
removeAdminPermission
(
req
.
params
.
id
,
token
);
return
res
.
status
(
200
).
send
(
user
);
}
catch
(
error
)
{
const
e
=
error
as
Error
;
...
...
This diff is collapsed.
Click to expand it.
src/Services/UserAPI.ts
+
29
−
48
View file @
6209a4c3
...
...
@@ -30,69 +30,50 @@ const create = (user: any): any => {
});
};
const
login
=
(
user
:
any
):
any
=>
{
instance
.
post
(
'
/login
'
,
user
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
{
throw
(
err
);
});
const
login
=
async
(
user
:
any
)
=>
{
const
res
=
await
instance
.
post
(
'
/login
'
,
user
);
return
res
.
data
;
};
const
listUsers
=
(
requirements
:
any
):
any
=>
{
instance
.
get
(
'
/
'
,
requirements
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
{
throw
(
err
);
});
const
listUsers
=
async
(
userType
:
any
,
token
:
string
)
=>
{
const
res
=
await
instance
.
get
(
'
/
'
,
{
headers
:
{
authorization
:
token
},
params
:
{
type
:
userType
}
});
return
res
.
data
;
};
const
update
=
(
user
:
any
,
idUser
:
string
)
=>
{
const
update
=
async
(
user
:
any
,
idUser
:
string
,
token
:
string
)
=>
{
const
url
=
`/
${
idUser
}
`
;
instance
.
put
(
url
,
user
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
{
throw
(
err
);
});
const
res
=
await
instance
.
put
(
url
,
user
,
{
headers
:
{
authorization
:
token
}
});
return
res
.
data
;
};
const
password
=
(
user
:
any
,
idUser
:
string
)
=>
{
instance
.
put
(
'
/password
'
,
user
,
{
params
:
{
id
:
idUser
}
})
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
{
throw
(
err
);
});
const
password
=
async
(
user
:
any
,
idUser
:
string
,
token
:
string
)
=>
{
const
url
=
`/
${
idUser
}
/password`
;
const
res
=
await
instance
.
put
(
url
,
user
,
{
headers
:
{
authorization
:
token
}
});
return
res
.
data
;
};
const
approve
=
(
idUser
:
string
)
=>
{
instance
.
put
(
'
/approve
'
,
{
params
:
{
id
:
idUser
}
})
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
{
throw
(
err
);
});
const
approve
=
async
(
idUser
:
string
,
token
:
string
)
=>
{
const
url
=
`/
${
idUser
}
/approve`
;
const
res
=
await
instance
.
put
(
url
,
{},
{
headers
:
{
authorization
:
token
}
});
return
res
.
data
;
};
const
cancel
=
(
idUser
:
string
)
=>
{
instance
.
put
(
'
/cancel
'
,
{
params
:
{
id
:
idUser
}
})
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
{
throw
(
err
);
});
const
cancel
=
async
(
idUser
:
string
,
token
:
string
)
=>
{
const
url
=
`/
${
idUser
}
/cancel`
;
const
res
=
await
instance
.
put
(
url
,
{},
{
headers
:
{
authorization
:
token
}
});
return
res
.
data
;
};
const
giveAdminPermission
=
(
idUser
:
string
)
=>
{
instance
.
put
(
'
/admin
'
,
{
params
:
{
id
:
idUser
}
})
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
{
throw
(
err
);
});
const
giveAdminPermission
=
async
(
idUser
:
string
,
token
:
string
)
=>
{
const
url
=
`/
${
idUser
}
/admin`
;
const
res
=
await
instance
.
put
(
url
,
{},
{
headers
:
{
authorization
:
token
}
});
return
res
.
data
;
};
const
removeAdminPermission
=
(
idUser
:
string
)
=>
{
instance
.
put
(
'
/client
'
,
{
params
:
{
id
:
idUser
}
})
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
{
throw
(
err
);
});
const
removeAdminPermission
=
async
(
idUser
:
string
,
token
:
string
)
=>
{
const
url
=
`/
${
idUser
}
/client`
;
const
res
=
await
instance
.
put
(
url
,
{},
{
headers
:
{
authorization
:
token
}
});
return
res
.
data
;
};
export
default
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment