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

Handle gitlab registration error. #250

Merged
merged 1 commit into from
Nov 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/controllers/GitlabController.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,21 @@ async function addUserToGroupCallback(req, res) {
throw new errors.ValidationError('Missing code.');
}
const group = await helper.ensureExists(OwnerUserGroup, {identifier}, 'OwnerUserGroup');

if (!group) {
throw new errors.NotFoundError('The group is not found or not accessible.');
}

// get owner user
const ownerUser = await helper.ensureExists(User,
{username: group.ownerUsername, type: constants.USER_TYPES.GITLAB, role: constants.USER_ROLES.OWNER}, 'User');

if (!ownerUser) {
throw new errors.NotFoundError('The owner user is not found or not accessible.');
}

// refresh the owner user access token if needed
if (ownerUser.accessTokenExpiration.getTime() <=
if (ownerUser.accessTokenExpiration && ownerUser.accessTokenExpiration.getTime() <=
new Date().getTime() + constants.GITLAB_REFRESH_TOKEN_BEFORE_EXPIRATION * MS_PER_SECOND) {
const refreshTokenResult = await request
.post('https://gitlab.com/oauth/token')
Expand Down