Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit f933c36

Browse files
authored
Merge pull request #250 from afrisalyp/issue-249
Handle gitlab registration error.
2 parents 52a2055 + 1e6fee9 commit f933c36

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/controllers/GitlabController.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,21 @@ async function addUserToGroupCallback(req, res) {
157157
throw new errors.ValidationError('Missing code.');
158158
}
159159
const group = await helper.ensureExists(OwnerUserGroup, {identifier}, 'OwnerUserGroup');
160+
161+
if (!group) {
162+
throw new errors.NotFoundError('The group is not found or not accessible.');
163+
}
164+
160165
// get owner user
161166
const ownerUser = await helper.ensureExists(User,
162167
{username: group.ownerUsername, type: constants.USER_TYPES.GITLAB, role: constants.USER_ROLES.OWNER}, 'User');
163168

169+
if (!ownerUser) {
170+
throw new errors.NotFoundError('The owner user is not found or not accessible.');
171+
}
172+
164173
// refresh the owner user access token if needed
165-
if (ownerUser.accessTokenExpiration.getTime() <=
174+
if (ownerUser.accessTokenExpiration && ownerUser.accessTokenExpiration.getTime() <=
166175
new Date().getTime() + constants.GITLAB_REFRESH_TOKEN_BEFORE_EXPIRATION * MS_PER_SECOND) {
167176
const refreshTokenResult = await request
168177
.post('https://gitlab.com/oauth/token')

0 commit comments

Comments
 (0)