Skip to content

Commit 7987547

Browse files
committed
refactor: remove whitelisted users logic from AuthService
1 parent 78f4633 commit 7987547

File tree

2 files changed

+0
-37
lines changed

2 files changed

+0
-37
lines changed

server/src/auth/auth.module.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ export class AuthModule {
9696
useFactory: (configService: ConfigService) =>
9797
configService.getOrThrow<string>('JWT_REFRESH_EXPIRES_IN'),
9898
},
99-
{
100-
inject: [ConfigService],
101-
provide: 'WHITELISTED_USERS',
102-
useFactory: (configService: ConfigService) =>
103-
configService.getOrThrow<string>('WHITELISTED_USERS'),
104-
},
10599
{
106100
inject: [ConfigService],
107101
provide: 'MAGIC_LINK_SECRET',

server/src/auth/auth.service.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ export class AuthService {
3434
private readonly JWT_REFRESH_SECRET: string,
3535
@Inject('JWT_REFRESH_EXPIRES_IN')
3636
private readonly JWT_REFRESH_EXPIRES_IN: string,
37-
@Inject('WHITELISTED_USERS')
38-
private readonly WHITELISTED_USERS: string,
3937
@Inject('APP_DOMAIN')
4038
private readonly APP_DOMAIN?: string,
4139
) {}
@@ -83,10 +81,6 @@ export class AuthService {
8381
profileImage: user.photos[0].value,
8482
};
8583

86-
if (!(await this.verifyWhitelist(profile.username))) {
87-
return res.redirect(this.FRONTEND_URL + '/login');
88-
}
89-
9084
// verify if user exists
9185
const user_registered = await this.verifyAndGetUser(profile);
9286

@@ -123,23 +117,6 @@ export class AuthService {
123117
return user_registered;
124118
}
125119

126-
private async verifyWhitelist(username: string) {
127-
const whitelist = this.WHITELISTED_USERS;
128-
129-
if (whitelist.length === 0) {
130-
return true;
131-
}
132-
133-
if (whitelist.includes(username.toLowerCase())) {
134-
this.logger.log(`User ${username} is whitelisted; approving login`);
135-
return true;
136-
}
137-
138-
this.logger.log(`User ${username} is not whitelisted; rejecting login`);
139-
140-
return false;
141-
}
142-
143120
public async githubLogin(req: Request, res: Response) {
144121
const user = req.user as GithubAccessToken;
145122
const { profile } = user;
@@ -156,10 +133,6 @@ export class AuthService {
156133

157134
const email = response.data.filter((email) => email.primary)[0].email;
158135

159-
if (!(await this.verifyWhitelist(profile.username))) {
160-
return res.redirect(this.FRONTEND_URL + '/login');
161-
}
162-
163136
const user_registered = await this.verifyAndGetUser({
164137
username: profile.username,
165138
email: email,
@@ -180,10 +153,6 @@ export class AuthService {
180153
profileImage: profilePictureUrl,
181154
};
182155

183-
if (!(await this.verifyWhitelist(profile.username))) {
184-
return res.redirect(this.FRONTEND_URL + '/login');
185-
}
186-
187156
// verify if user exists
188157
const user_registered = await this.verifyAndGetUser(profile);
189158

0 commit comments

Comments
 (0)