|
6 | 6 | import org.mskcc.cbio.oncokb.domain.Token;
|
7 | 7 | import org.mskcc.cbio.oncokb.domain.User;
|
8 | 8 | import org.mskcc.cbio.oncokb.domain.enumeration.LicenseStatus;
|
| 9 | +import org.mskcc.cbio.oncokb.domain.enumeration.LicenseType; |
9 | 10 | import org.mskcc.cbio.oncokb.repository.UserRepository;
|
10 |
| -import org.mskcc.cbio.oncokb.security.AuthoritiesConstants; |
11 | 11 | import org.mskcc.cbio.oncokb.security.SecurityUtils;
|
12 | 12 | import org.mskcc.cbio.oncokb.security.uuid.TokenProvider;
|
13 | 13 | import org.mskcc.cbio.oncokb.service.*;
|
@@ -197,13 +197,21 @@ private boolean activateUser(
|
197 | 197 | slackService.sendUserRegistrationToChannel(userDTO, userService.isUserOnTrial(userDTO), limitedCompany);
|
198 | 198 | } else {
|
199 | 199 | Company company = companyCandidate.getCompanyCandidate().get();
|
200 |
| - userService.updateUserWithCompanyLicense(userDTO, company, false, false); |
201 |
| - // Don't send the automated approval message to slack if the company is on trial |
202 |
| - // We only want a message when the user accepts the trial license agreement. |
203 | 200 | if (company.getLicenseStatus().equals(LicenseStatus.REGULAR)) {
|
204 |
| - userService.approveUser(userDTO, false); |
205 |
| - slackService.sendApprovedConfirmation(userDTO, company); |
206 |
| - userIsActivated = true; |
| 201 | + Optional<Boolean> apiRequestedOptional = Optional.ofNullable(userDTO.getAdditionalInfo()) |
| 202 | + .map(AdditionalInfoDTO::getApiAccessRequest) |
| 203 | + .map(ApiAccessRequest::isRequested); |
| 204 | + if (apiRequestedOptional.isPresent() && apiRequestedOptional.get() && LicenseType.ACADEMIC.equals(company.getLicenseType())) { |
| 205 | + // if user specifically asked for API access, we need to send the justification to user channel for approval |
| 206 | + slackService.sendUserRegistrationToChannel(userDTO, userService.isUserOnTrial(userDTO), company); |
| 207 | + } else { |
| 208 | + // Don't send the automated approval message to slack if the company is on trial |
| 209 | + // We only want a message when the user accepts the trial license agreement. |
| 210 | + userService.updateUserWithCompanyLicense(userDTO, company, false, false); |
| 211 | + userService.approveUser(userDTO, false); |
| 212 | + slackService.sendApprovedConfirmation(userDTO, company); |
| 213 | + userIsActivated = true; |
| 214 | + } |
207 | 215 | }
|
208 | 216 | }
|
209 | 217 |
|
|
0 commit comments