Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create default organisation for signup user #617

Merged
merged 5 commits into from
Aug 24, 2024

Conversation

Ofektom
Copy link
Collaborator

@Ofektom Ofektom commented Aug 24, 2024

Description

When a new user signs up, they should be automatically assigned to a default organisation with name (first_name's Organisation). This ensures that each user is part of an organisation by default, allowing them to immediately start using features that require organisational context.

Key changes:

  • Created a private method to split the full name of the user saved in the database to first name and last name
  • Created a private method to create default organisation with the name "fisrt_name's Organisation" in the user service implementation class
  • Called the createDefaultOrganisation method in the registerUser method to create the registerUser method to create an organisation for the user while signing up.

How to manually test:

Endpoint:

/api/v1/auth/register

Request Body:

{
    "first_name": "Blessed",
	"last_name": "Doe",
	"email": "blesseddoe@example.com",
	"password": "password123"
}

Response Body

{
    "status_code": 201,
    "message": "Registration Successful!",
    "data": {
        "token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJva3BvaG90QGdtYWlsLmNvbSIsImlhdCI6MTcyNDQ4NjI5NCwiZXhwIjoxNzI0NDg5ODk0fQ.5ZaMingshJhjwrqpjFu5Q0zUrwoYCpcnfA6c6oTcxtyzA45MiG0AdVc8kqpYP1SHkBD3x3nNHn88bbYjc7O3wQ",
        "user": {
            "id": "988a0b83-6bd4-4c50-b675-b45c343c2ec4",
            "first_name": "Blessed",
            "last_name": "Doe",
            "email": "blesseddoe@example.com",
            "role": null,
            "imr_url": null,
            "organisations": [
                {
                    "id": "1d658df9-9e2a-4c80-8d3d-3a6ff47469d7",
                    "name": "Blessed's Organisation",
                    "description": "Default organisation for Blessed",
                    "slug": null,
                    "email": null,
                    "industry": null,
                    "type": null,
                    "country": null,
                    "address": null,
                    "state": null,
                    "createdAt": "2024-08-24T08:58:13.745934",
                    "updatedAt": "2024-08-24T08:58:13.745976",
                    "owner": "988a0b83-6bd4-4c50-b675-b45c343c2ec4"
                }
            ],
            "created_at": "2024-08-24T08:58:13.666572"
        }
    }
}

Relates Issue

Refer to the issue

@Ofektom Ofektom closed this Aug 24, 2024
@Ofektom Ofektom reopened this Aug 24, 2024
@Ofektom
Copy link
Collaborator Author

Ofektom commented Aug 24, 2024

@Am0du @lurldgbodex please review this

Am0du
Am0du previously approved these changes Aug 24, 2024
Adewale66
Adewale66 previously approved these changes Aug 24, 2024
Copy link
Collaborator

@Adewale66 Adewale66 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @Am0du

@Ofektom Ofektom dismissed stale reviews from Adewale66 and Am0du via 7ae4900 August 24, 2024 10:35
@Ofektom
Copy link
Collaborator Author

Ofektom commented Aug 24, 2024

@Am0du @Adewale66 Conflict resolved

@Adewale66
Copy link
Collaborator

LGTM @Am0du

@Am0du
Copy link
Contributor

Am0du commented Aug 24, 2024

@Ofektom Please use the specified body so i can merge this

@Am0du Am0du merged commit 379f879 into dev Aug 24, 2024
3 checks passed
@Ofektom Ofektom deleted the fix/create-user-default-organisation branch August 26, 2024 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants