Example #1
0
        public async Task Leave(string id)
        {
            var orgGuidId = new Guid(id);

            if (!_currentContext.OrganizationUser(orgGuidId))
            {
                throw new NotFoundException();
            }

            var userId = _userService.GetProperUserId(User);
            await _organizationService.DeleteUserAsync(orgGuidId, userId.Value);
        }
Example #2
0
        public async Task <CipherResponseModel> Post([FromBody] CipherRequestModel model)
        {
            var userId = _userService.GetProperUserId(User).Value;
            var cipher = model.ToCipherDetails(userId);

            if (cipher.OrganizationId.HasValue && !_currentContext.OrganizationUser(cipher.OrganizationId.Value))
            {
                throw new NotFoundException();
            }

            await _cipherService.SaveDetailsAsync(cipher, userId, model.LastKnownRevisionDate, null, cipher.OrganizationId.HasValue);

            var response = new CipherResponseModel(cipher, _globalSettings);

            return(response);
        }
Example #3
0
        public async Task Leave(string id)
        {
            var orgGuidId = new Guid(id);

            if (!await _currentContext.OrganizationUser(orgGuidId))
            {
                throw new NotFoundException();
            }

            var user = await _userService.GetUserByPrincipalAsync(User);

            var ssoConfig = await _ssoConfigRepository.GetByOrganizationIdAsync(orgGuidId);

            if (ssoConfig?.GetData()?.KeyConnectorEnabled == true &&
                user.UsesKeyConnector)
            {
                throw new BadRequestException("Your organization's Single Sign-On settings prevent you from leaving.");
            }


            await _organizationService.DeleteUserAsync(orgGuidId, user.Id);
        }