Esempio n. 1
0
        public void IsInvitedDisabledTest()
        {
            string testEmail = "*****@*****.**";

            var inviteOnlyConfig = new InviteOnlyModeConfiguration {
                Enabled = false, Domains = new string[] { }, Addresses = new string[] { }
            };
            InviteOnlyChecker checker = new InviteOnlyChecker(inviteOnlyConfig);

            bool isInvited = checker.IsInvited(testEmail);

            Assert.True(isInvited);
        }
Esempio n. 2
0
        public void IsInvitedDomainsAndOtherEmailTest()
        {
            string invitedEmail    = "*****@*****.**";
            string nonInvitedEmail = "*****@*****.**";

            var inviteOnlyConfig = new InviteOnlyModeConfiguration {
                Enabled = true, Domains = new string[] { "autodesk.com" }, Addresses = new string[] { invitedEmail }
            };
            InviteOnlyChecker checker = new InviteOnlyChecker(inviteOnlyConfig);

            bool isInvited = checker.IsInvited(invitedEmail);

            Assert.True(isInvited);

            isInvited = checker.IsInvited(nonInvitedEmail);
            Assert.False(isInvited);
        }
        public async Task <ActionResult <ProfileDTO> > Profile()
        {
            _logger.LogInformation("Get profile");
            if (_profileProvider.IsAuthenticated)
            {
                dynamic profile = await _profileProvider.GetProfileAsync();

                if (_inviteOnlyModeConfig.Enabled)
                {
                    var inviteOnlyChecker = new InviteOnlyChecker(_inviteOnlyModeConfig);
                    if (!profile.emailVerified || !inviteOnlyChecker.IsInvited(profile.emailId))
                    {
                        return(StatusCode(403));
                    }
                }
                return(new ProfileDTO {
                    Name = profile.firstName + " " + profile.lastName, AvatarUrl = profile.profileImages.sizeX40
                });
            }
            else
            {
                return(AnonymousProfile);
            }
        }