Samagra-Development / user-service

Additional Services related to user management in eSamwad
MIT License
5 stars 22 forks source link

fix: refactor fusionauth service #22

Closed radhay-samagra closed 2 years ago

radhay-samagra commented 2 years ago

Description

Exception Handling for http req within service and Code refactoring

Changes

How to test

Expected response:

Success

{
"registration": {
"applicationId": "1ae074db-32f3-4714-a150-cc8a370eafd1",
"preferredLanguages": [
"en"
],
"roles": [
"BPO"
],
"timezone": "Asia/Kolkata",
"username": "ra_dhay3",
"usernameStatus": "ACTIVE"
},
"user": {
"fullName": "test",
"data": {
"roleData": {
"block": "JHANDUTTA",
"designation": "BPO",
"district": "BILASPUR",
"geographic_level": "Block"
},
"phone": "8219781037",
"accountName": "test"
},
"preferredLanguages": [
"en"
],
"timezone": "Asia/Kolkata",
"usernameStatus": "ACTIVE",
"username": "ra_dhay3",
"mobilePhone": "8219781037",
"password": "himachal12345"
}
}

Error

{
"statusCode": 400,
"exception": {
"fieldErrors": {
"user.email": [
{
"code": "[duplicate]user.email",
"message": "A User with email [hekk@gmail.com] already exists."
}
]
}
}
}

Sample Request - Update User:

curl --location --request PATCH '{{host-url}}/admin/updateUser/d8308009-37c0-41ad-a60c-7542ec48e73f' \
--header 'Authorization: Bearer  {{token}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "data": {
        "roleData": {
            "block": "block"
        }
    }
}'

Expected Response:

{
    "responseCode": "OK",
    "params": {
        "responseMsgId": "7665009b-3744-4090-a5ca-fa5f582a3490",
        "msgId": "27f2229b-64e3-45fc-9e52-1466a2eff240",
        "err": "",
        "status": "Success",
        "errMsg": ""
    },
    "ts": "2022-05-12T04:55:12.951Z",
    "id": "44c6599d-34ed-4223-9368-282098d8c2b0",
    "result": {
        "active": true,
        "connectorId": "e3306678-a53a-4964-9040-1c96f36dda72",
        "data": {
            "roleData": {
                "block": "block"
            }
        },
        "id": "d8308009-37c0-41ad-a60c-7542ec48e73f",
        "insertInstant": 1650636317539,
        "lastLoginInstant": 1650636317631,
        "lastUpdateInstant": 1652331313026,
        "passwordChangeRequired": false,
        "passwordLastUpdateInstant": 1650636317616,
        "preferredLanguages": [
            "en"
        ],
        "registrations": [
            {
                "applicationId": "f0ddb3f6-091b-45e4-8c0f-889f89d4f5da",
                "id": "f44b487d-8df8-4105-b706-e63e63183bd6",
                "insertInstant": 1650636317629,
                "lastLoginInstant": 1650636317631,
                "lastUpdateInstant": 1650636317629,
                "preferredLanguages": [
                    "en"
                ],
                "timezone": "Asia/Kolkata",
                "username": "test1234",
                "usernameStatus": "ACTIVE",
                "verified": true
            }
        ],
        "tenantId": "064458d0-dd05-e293-3709-a06cc6ca5ed7",
        "timezone": "Asia/Kolkata",
        "twoFactorDelivery": "None",
        "twoFactorEnabled": false,
        "username": "test1234",
        "usernameStatus": "ACTIVE",
        "verified": true
    }
}

Please consider using the closing keyword if the pull request is proposed to fix an issue already created in the repository (https://help.github.com/articles/closing-issues-using-keywords/)

coveralls commented 2 years ago

Pull Request Test Coverage Report for Build 2313842737


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/admin/admin.service.ts 0 2 0.0%
<!-- Total: 3 5 60.0% -->
Totals Coverage Status
Change from base Build 2313410300: 0.1%
Covered Lines: 341
Relevant Lines: 1301

💛 - Coveralls