Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
user-service
Commits
14367e6e
Unverified
Commit
14367e6e
authored
2 years ago
by
radhay-samagra
Committed by
GitHub
2 years ago
Browse files
Options
Download
Plain Diff
Merge pull request #22 from Samarth-HP/develop
fix: refactor fusionauth service
parents
a0f06a2d
6e6d371f
master
v2.4.4
v2.4.3
v2.4.2
v2.4.1
v2.4.0
v2.3.9
v2.3.8
v2.3.7
v2.3.6
v2.3.5
v2.3.4
v2.3.3.1
v2.3.3
v2.3.2
v2.3.1
v2.3.0
v2.2.0
v2.1.7
v2.1.6
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/admin/admin.controller.ts
+2
-2
src/admin/admin.controller.ts
src/admin/admin.interface.ts
+5
-1
src/admin/admin.interface.ts
src/admin/admin.service.ts
+5
-5
src/admin/admin.service.ts
src/admin/fusionauth/fusionauth.service.ts
+5
-5
src/admin/fusionauth/fusionauth.service.ts
with
17 additions
and
13 deletions
+17
-13
src/admin/admin.controller.ts
+
2
−
2
View file @
14367e6e
...
...
@@ -2,7 +2,7 @@ import { User } from '@fusionauth/typescript-client';
import
{
Body
,
Controller
,
Request
,
Get
,
Param
,
Patch
,
Post
,
Query
,
UseGuards
}
from
'
@nestjs/common
'
;
import
{
AuthGuard
}
from
'
@nestjs/passport
'
;
import
{
JwtAuthGuard
}
from
'
../auth/auth-jwt.guard
'
;
import
{
SignupResponse
,
UsersResponse
}
from
'
./admin.interface
'
;
import
{
SignupResponse
,
UserRegistration
,
UsersResponse
}
from
'
./admin.interface
'
;
import
{
AdminService
}
from
'
./admin.service
'
;
import
{
Roles
}
from
'
./roles.decorator
'
;
...
...
@@ -31,7 +31,7 @@ export class AdminController {
@
Post
(
'
/createUser
'
)
@
Roles
(
'
Admin
'
)
@
UseGuards
(
JwtAuthGuard
)
async
createUser
(@
Body
()
data
:
User
):
Promise
<
SignupResponse
>
{
async
createUser
(@
Body
()
data
:
User
Registration
):
Promise
<
SignupResponse
>
{
const
users
:
SignupResponse
=
await
this
.
adminService
.
createUser
(
data
);
return
users
;
}
...
...
This diff is collapsed.
Click to expand it.
src/admin/admin.interface.ts
+
5
−
1
View file @
14367e6e
import
{
User
,
UUID
}
from
'
@fusionauth/typescript-client
'
;
import
{
RegistrationRequest
,
User
,
UUID
}
from
'
@fusionauth/typescript-client
'
;
import
{
SignupResult
}
from
'
src/user/user.interface
'
;
import
{
v4
as
uuidv4
}
from
'
uuid
'
;
...
...
@@ -116,4 +116,8 @@ export interface Admin {
throw
new
Error
(
'
Method not implemented.
'
);
}
}
export
class
UserRegistration
implements
RegistrationRequest
{
}
This diff is collapsed.
Click to expand it.
src/admin/admin.service.ts
+
5
−
5
View file @
14367e6e
import
{
Error
,
User
,
UserRequest
,
UUID
}
from
'
@fusionauth/typescript-client
'
;
import
{
Error
,
User
,
UUID
}
from
'
@fusionauth/typescript-client
'
;
import
{
HttpService
}
from
'
@nestjs/axios
'
;
import
{
HttpException
,
HttpStatus
,
Injectable
}
from
'
@nestjs/common
'
;
import
{
ResponseCode
,
ResponseStatus
,
SignupResponse
,
UserRegistration
,
UsersResponse
,
}
from
'
./admin.interface
'
;
import
{
FAStatus
,
FusionauthService
}
from
'
./fusionauth/fusionauth.service
'
;
...
...
@@ -53,7 +54,6 @@ export class AdminService {
numberOfResults
,
);
const
response
:
UsersResponse
=
new
UsersResponse
().
init
(
uuidv4
());
console
.
log
(
response
);
if
(
users
!=
null
)
{
response
.
responseCode
=
ResponseCode
.
OK
;
response
.
params
.
status
=
ResponseStatus
.
success
;
...
...
@@ -68,12 +68,12 @@ export class AdminService {
}
async
updatePassword
(
data
:
{
loginId
:
string
,
password
:
string
}):
Promise
<
any
>
{
return
this
.
fusionAuthService
.
chang
ePassword
(
data
);
return
this
.
fusionAuthService
.
upddat
ePassword
WithLoginId
(
data
);
}
async
createUser
(
data
:
User
):
Promise
<
SignupResponse
>
{
async
createUser
(
data
:
User
Registration
):
Promise
<
SignupResponse
>
{
const
{
userId
,
user
,
err
}:
{
userId
:
UUID
;
user
:
User
;
err
:
Error
}
=
await
this
.
fusionAuthService
.
create
User
({
u
ser
:
data
}
);
await
this
.
fusionAuthService
.
create
AndRegisterU
ser
(
data
);
if
(
userId
==
null
||
user
==
null
)
{
throw
new
HttpException
(
err
,
HttpStatus
.
BAD_REQUEST
);
}
...
...
This diff is collapsed.
Click to expand it.
src/admin/fusionauth/fusionauth.service.ts
+
5
−
5
View file @
14367e6e
...
...
@@ -154,7 +154,7 @@ export class FusionauthService {
});
}
updatePassword
(
updatePassword
WithUserId
(
userId
:
UUID
,
password
:
string
,
):
Promise
<
{
statusFA
:
FAStatus
;
userId
:
UUID
}
>
{
...
...
@@ -434,12 +434,12 @@ export class FusionauthService {
}
}
async
create
User
(
user
:
User
Request
):
Promise
<
{
userId
:
UUID
,
user
:
User
,
err
:
Error
}
>
{
async
create
AndRegisterUser
(
user
:
Registration
Request
):
Promise
<
{
userId
:
UUID
,
user
:
User
,
err
:
Error
}
>
{
return
this
.
fusionauthClient
.
c
re
ateUs
er
(
null
,
user
)
.
re
gist
er
(
null
,
user
)
.
then
(
(
response
:
ClientResponse
<
User
Response
>
,
response
:
ClientResponse
<
Registration
Response
>
,
):
{
userId
:
UUID
;
user
:
User
,
err
:
Error
}
=>
{
console
.
log
(
'
Found user
'
);
return
{
...
...
@@ -484,7 +484,7 @@ export class FusionauthService {
});
}
async
chang
ePassword
(
data
:
{
loginId
:
string
,
password
:
string
}):
Promise
<
any
>
{
async
upddat
ePassword
WithLoginId
(
data
:
{
loginId
:
string
,
password
:
string
}):
Promise
<
any
>
{
return
this
.
httpService
.
post
(
process
.
env
.
FUSIONAUTH_BASE_URL
+
'
/api/user/change-password
'
,
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets