Skip to content

Develop#2

Merged
Zaiidmo merged 57 commits intomasterfrom
develop
Jan 26, 2026
Merged

Develop#2
Zaiidmo merged 57 commits intomasterfrom
develop

Conversation

@Zaiidmo
Copy link
Copy Markdown
Contributor

@Zaiidmo Zaiidmo commented Jan 26, 2026

No description provided.

…ariables retrieval in auth service, added a simple log for admin Id after seeds run
@Zaiidmo Zaiidmo requested review from a team and Copilot January 26, 2026 12:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR represents a major refactor transitioning from a basic authentication system to a comprehensive, production-ready authentication kit with enhanced OAuth support, RBAC, and admin user management.

Changes:

  • Migrated from plain Mongoose models to NestJS @nestjs/mongoose decorators with proper service/repository architecture
  • Implemented comprehensive JWT-based authentication with email verification, password reset, and automatic token invalidation
  • Added OAuth support for Google, Microsoft, and Facebook with both web redirect and mobile token exchange flows

Reviewed changes

Copilot reviewed 48 out of 50 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/utils/helper.ts Added username generation utility function
src/services/*.service.ts New service layer for auth, users, roles, permissions, OAuth, mail, and seeding
src/repositories/*.repository.ts New repository layer abstracting database operations
src/models/*.model.ts Migrated to NestJS @Schema decorators, removed legacy models (tenant, client)
src/middleware/*.guard.ts Refactored authentication guards, added admin guard and role-based guards
src/controllers/*.controller.ts Simplified controllers to use service layer, removed password-reset and admin controllers
src/config/passport.config.ts Refactored OAuth strategies to use service layer
src/auth-kit.module.ts Complete module restructure with proper DI and Mongoose integration
package.json Updated dependencies and peer dependencies for NestJS 10/11 compatibility
README.md Comprehensive documentation overhaul with API routes, examples, and setup guide
.env.example New environment variable template
Comments suppressed due to low confidence (1)

src/config/passport.config.ts:97

  • There is an extra blank line at the end of the microsoftCallback method. This should be removed for consistency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (await this.roles.findByName(dto.name)) throw new Error('Role already exists.');
const permIds = (dto.permissions || []).map((p) => new Types.ObjectId(p));
return this.roles.create({ name: dto.name, permissions: permIds });

Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

There is an extra blank line after the return statement in the create method. This should be removed to maintain consistency with other methods in the file.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +47


Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

There are two unnecessary blank lines at the end of the setPermissions method. These should be removed for consistency.

Suggested change

Copilot uses AI. Check for mistakes.
let user = await this.roles.findByName('user');
if (!user) user = await this.roles.create({ name: 'user', permissions: [] });


Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

There is an extra blank line before the console.log statement. This should be removed for consistency.

Suggested change

Copilot uses AI. Check for mistakes.
return v;
}


Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

There is an extra blank line after the getEnv method. This should be removed to maintain consistent spacing.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines +90 to +91


Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

There is an extra blank line in the middle of the register method logic. This should be removed to maintain consistent spacing.

Suggested change

Copilot uses AI. Check for mistakes.
return { accessToken, refreshToken };
}


Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

There is an extra blank line at the end of the issueTokensForUser method. This should be removed for consistency.

Suggested change

Copilot uses AI. Check for mistakes.
permissions?: string[];
}


Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

There are two extra blank lines between class definitions. Only one blank line should be used to separate classes.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +23
if (await this.users.findByEmail(dto.email)) throw new Error('Email already in use.');
if (await this.users.findByUsername(dto.username)) throw new Error('Username already in use.');
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

The error messages 'Email already in use.' and 'Username already in use.' are not consistent with similar validation messages in auth.service.ts which don't include the trailing period. For consistency across the codebase, either add or remove the period from all similar error messages.

Copilot uses AI. Check for mistakes.

async setBan(id: string, banned: boolean) {
const user = await this.users.updateById(id, { isBanned: banned });
if (!user) throw new Error('User not found.');
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

The error message 'User not found.' includes a trailing period while other similar messages in the same file do not. This should be made consistent.

Suggested change
if (!user) throw new Error('User not found.');
if (!user) throw new Error('User not found');

Copilot uses AI. Check for mistakes.
@Zaiidmo Zaiidmo merged commit 404799d into master Jan 26, 2026
2 checks passed
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.

2 participants