Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Surname,Forename,Birthday,EmailAdress,PhoneNumber")] MembershipRequest membershipRequest)
        {
            if (id != membershipRequest.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(membershipRequest);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MembershipRequestExists(membershipRequest.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(membershipRequest));
        }
        public void CreateMembership()
        {
            // If this test fails, check whether your API user has the permissions
            // access civimember and edit memberships.
            using (var client = TestHelper.ClientGet())
            {
                var membershipRequest = new MembershipRequest
                {
                    MembershipTypeId = SomeMembershipTypeId,
                    ContactId        = _myContactId1,
                    JoinDate         = DateTime.Now.Date,
                    StartDate        = DateTime.Now.Date,
                    Status           = MembershipStatus.Pending
                };

                var result        = client.MembershipSave(TestHelper.ApiKey, TestHelper.SiteKey, membershipRequest);
                var newMembership = result.Values.First();

                Assert.AreEqual(membershipRequest.MembershipTypeId, newMembership.MembershipTypeId);
                Assert.AreEqual(membershipRequest.ContactId, newMembership.ContactId);
                Assert.AreEqual(membershipRequest.JoinDate, newMembership.JoinDate);
                Assert.AreEqual(membershipRequest.StartDate, newMembership.StartDate);
                Assert.AreEqual(membershipRequest.Status, newMembership.Status);
            }
        }
Ejemplo n.º 3
0
        public static void ResetUserPassword(string username, string newPassword, bool sendEmail, SPWeb web)
        {
            if (Utils.BaseMembershipProvider().RequiresQuestionAndAnswer || !Utils.BaseMembershipProvider().EnablePasswordReset)
            {
                throw new Exception(LocalizedString.GetGlobalString("FBAPackWebPages", "ResetPasswordUnavailable"));
            }

            MembershipUser user     = Utils.BaseMembershipProvider().GetUser(username, false);
            string         password = user.ResetPassword();

            //Change the password to the specified password
            if (!String.IsNullOrEmpty(newPassword))
            {
                if (user.ChangePassword(password, newPassword))
                {
                    password = newPassword;
                }
                else
                {
                    throw new Exception(LocalizedString.GetGlobalString("FBAPackWebPages", "ResetPasswordChangePasswordError"));
                }
            }

            if (sendEmail)
            {
                MembershipRequest request = MembershipRequest.GetMembershipRequest(user, web);
                request.Password = password;

                MembershipRequest.SendResetPasswordEmail(request, web);
            }
        }
Ejemplo n.º 4
0
        public MembershipRequest Execute()
        {
            var isMember = _db.Memberships.Any(m => m.User.Id == requester.Id && m.Group.Id == groupId);

            if (isMember)
            {
                throw new InvalidOperationException("Already a member of the group!");
            }

            var hasRequested = _db.Requests.Any(m => m.User.Id == requester.Id && m.Group.Id == groupId);

            if (hasRequested)
            {
                throw new InvalidOperationException("Already requested permission");
            }

            Group g = new Group
            {
                Id = groupId
            };

            _db.Groups.Attach(g);

            MembershipRequest mr = new MembershipRequest
            {
                User  = requester,
                Group = g
            };

            _db.Requests.Add(mr);
            _db.SaveChanges();

            return(mr);
        }
Ejemplo n.º 5
0
        void HandleGuildFinderGetApplications(LFGuildGetApplications lfGuildGetApplications)
        {
            List <MembershipRequest> applicatedGuilds    = Global.GuildFinderMgr.GetAllMembershipRequestsForPlayer(GetPlayer().GetGUID());
            LFGuildApplications      lfGuildApplications = new LFGuildApplications();

            lfGuildApplications.NumRemaining = 10 - Global.GuildFinderMgr.CountRequestsFromPlayer(GetPlayer().GetGUID());

            for (var i = 0; i < applicatedGuilds.Count; ++i)
            {
                MembershipRequest      application     = applicatedGuilds[i];
                LFGuildApplicationData applicationData = new LFGuildApplicationData();

                Guild           guild         = Global.GuildMgr.GetGuildByGuid(application.GetGuildGuid());
                LFGuildSettings guildSettings = Global.GuildFinderMgr.GetGuildSettings(application.GetGuildGuid());

                applicationData.GuildGUID              = application.GetGuildGuid();
                applicationData.GuildVirtualRealm      = Global.WorldMgr.GetVirtualRealmAddress();
                applicationData.GuildName              = guild.GetName();
                applicationData.ClassRoles             = guildSettings.GetClassRoles();
                applicationData.PlayStyle              = guildSettings.GetInterests();
                applicationData.Availability           = guildSettings.GetAvailability();
                applicationData.SecondsSinceCreated    = (uint)(Time.UnixTime - application.GetSubmitTime());
                applicationData.SecondsUntilExpiration = (uint)(application.GetExpiryTime() - Time.UnixTime);
                applicationData.Comment = application.GetComment();

                lfGuildApplications.Application.Add(applicationData);
            }

            GetPlayer().SendPacket(lfGuildApplications);
        }
Ejemplo n.º 6
0
        void HandleGuildFinderAddRecruit(LFGuildAddRecruit lfGuildAddRecruit)
        {
            if (Global.GuildFinderMgr.GetAllMembershipRequestsForPlayer(GetPlayer().GetGUID()).Count >= 10)
            {
                return;
            }

            if (!lfGuildAddRecruit.GuildGUID.IsGuild())
            {
                return;
            }
            if (!lfGuildAddRecruit.ClassRoles.HasAnyFlag((uint)GuildFinderOptionsRoles.All) || lfGuildAddRecruit.ClassRoles > (uint)GuildFinderOptionsRoles.All)
            {
                return;
            }
            if (!lfGuildAddRecruit.Availability.HasAnyFlag((uint)GuildFinderOptionsAvailability.Always) || lfGuildAddRecruit.Availability > (uint)GuildFinderOptionsAvailability.Always)
            {
                return;
            }
            if (!lfGuildAddRecruit.PlayStyle.HasAnyFlag((uint)GuildFinderOptionsInterest.All) || lfGuildAddRecruit.PlayStyle > (uint)GuildFinderOptionsInterest.All)
            {
                return;
            }

            MembershipRequest request = new MembershipRequest(GetPlayer().GetGUID(), lfGuildAddRecruit.GuildGUID, lfGuildAddRecruit.Availability,
                                                              lfGuildAddRecruit.ClassRoles, lfGuildAddRecruit.PlayStyle, lfGuildAddRecruit.Comment, Time.UnixTime);

            Global.GuildFinderMgr.AddMembershipRequest(lfGuildAddRecruit.GuildGUID, request);
        }
Ejemplo n.º 7
0
        private void RequestMembership()
        {
            this.socket.NotNull <MessengerSocket, MessengerAuthenticationException>("Authenticate first");

            MembershipRequest  request    = new MembershipRequest(this.Credentials["contacts.msn.com"].SecurityToken.Replace("&", "&amp;"));
            IList <Membership> membership = request.RequestMembership();

            this.Membership = membership;
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("Id,Surname,Forename,Birthday,EmailAdress,PhoneNumber")] MembershipRequest membershipRequest)
        {
            if (ModelState.IsValid)
            {
                _context.Add(membershipRequest);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(membershipRequest));
        }
Ejemplo n.º 9
0
        public MembershipRequest(MembershipRequest settings)
        {
            _comment = settings.GetComment();

            _availability = settings.GetAvailability();
            _classRoles   = settings.GetClassRoles();
            _interests    = settings.GetInterests();
            _guildId      = settings.GetGuildGuid();
            _playerGUID   = settings.GetPlayerGUID();
            _time         = settings.GetSubmitTime();
        }
        public IActionResult ValidateMembershipNumber([FromBody] MembershipRequest request)
        {
            if (!IsStoreMembershipNumberValid(request.StoreMembershipNumber))
            {
                return(GenerateErrorMessageWithMessage("Store membership number is not valid, it must be a multiple of 5!"));
            }

            // Return the output claim(s)
            return(Ok(new ValidationResponseContent
            {
                StoreMembershipNumber = request.StoreMembershipNumber.ToString()
            }));
        }
Ejemplo n.º 11
0
 public static MembershipRequestDto ToDto(this MembershipRequest request)
 {
     return(new MembershipRequestDto
     {
         Status = request.Status,
         Nickname = request.Nickname,
         Id = request.Id,
         LastActivity = request.LastActivity,
         SelectedFromExisting = request.SelectedFromExisting,
         Created = request.Created,
         UserInfo = request.User.ToMainInfoDto()
     });
 }
        public void GetMembership()
        {
            var membershipRequest = new MembershipRequest
            {
                ContactId = _myContactId2
            };

            using (var client = TestHelper.ClientGet())
            {
                var result = client.MembershipGet(TestHelper.ApiKey, TestHelper.SiteKey, membershipRequest);

                Assert.AreEqual(1, result.Count);
            }
        }
            private static void AddOrganizationRequests(User testUser, bool isAdmin)
            {
                var testOrganization = new Organization("testOrganization")
                {
                    Key = Key++
                };

                var request = new MembershipRequest {
                    IsAdmin = isAdmin, NewMember = testUser, Organization = testOrganization
                };

                testOrganization.MemberRequests.Add(request);
                testUser.OrganizationRequests.Add(request);
            }
        public void RelationshipDateFilter()
        {
            var membershipRequest = new MembershipRequest
            {
                ContactId       = _myContactId2,
                StartDateFilter = new Filter <DateTime?>(WhereOperator.Gte, new DateTime(2016, 09, 21))
            };

            using (var client = TestHelper.ClientGet())
            {
                var result = client.MembershipGet(TestHelper.ApiKey, TestHelper.SiteKey, membershipRequest);

                Assert.AreEqual(1, result.Count);
            }
        }
        public void GetMembershipStatusFilter()
        {
            var membershipRequest = new MembershipRequest
            {
                ContactId    = _myContactId2,
                StatusFilter = new Filter <MembershipStatus>(WhereOperator.In, MembershipStatus.New, MembershipStatus.Current)
            };

            using (var client = TestHelper.ClientGet())
            {
                var result = client.MembershipGet(TestHelper.ApiKey, TestHelper.SiteKey, membershipRequest);

                Assert.AreEqual(1, result.Count);
            }
        }
        public void GetMembershipWithPayment()
        {
            var membershipRequest = new MembershipRequest
            {
                MembershipPaymentGetRequest = new MembershipPaymentRequest()
            };

            using (var client = TestHelper.ClientGet())
            {
                var result = client.MembershipGet(TestHelper.ApiKey, TestHelper.SiteKey, membershipRequest);

                Assert.IsTrue(result.Count >= 1);
                var first = result.Values.First();
                Assert.IsNotNull(first.MembershipPaymentResult);
            }
        }
        public IActionResult GetMembershipDate([FromBody] MembershipRequest request)
        {
            if (!IsStoreMembershipNumberValid(request.StoreMembershipNumber))
            {
                return(GenerateErrorMessageWithMessage("Store membership number is not valid, it must be a multiple of 5!"));
            }

            var membershipDate = ObtainStoreMembershipDate();

            return(Ok(new MembershipDateResponseContent
            {
                Version = "1.0.0",
                Status = (int)HttpStatusCode.OK,
                UserMessage = "Membership date located successfully.",
                StoreMembershipDate = membershipDate.ToString("d")
            }));
        }
        public void GetMembershipWithContact()
        {
            var membershipRequest = new MembershipRequest
            {
                ContactGetRequest = new ContactRequest(),
                ContactId         = _myContactId2
            };

            using (var client = TestHelper.ClientGet())
            {
                var result = client.MembershipGet(TestHelper.ApiKey, TestHelper.SiteKey, membershipRequest);

                Assert.IsTrue(result.Count >= 1);
                var first = result.Values.First();
                Assert.IsNotNull(first.ContactResult);
                Assert.AreEqual(_myContactId2, first.ContactResult.Values.First().Id);
            }
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> GetMembershipDate(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)]  MembershipRequest request)
        {
            if (!IsStoreMembershipNumberValid(request.StoreMembershipNumber))
            {
                return(GenerateErrorMessageWithMessage(
                           "Store membership number is not valid, it must be a " +
                           "multiple of 5!"));
            }

            var membershipDate = ObtainStoreMembershipDate();

            return(new OkObjectResult(new MembershipDateResponseContent
            {
                Version = "1.0.0",
                Status = (int)HttpStatusCode.OK,
                UserMessage = "Membership date located successfully.",
                StoreMembershipDate = membershipDate.ToString("d")
            }));
        }
Ejemplo n.º 20
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] MembershipRequest request,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            log.LogInformation($"request: {JsonConvert.SerializeObject(request)}");

            if (!IsStoreMembershipNumberValid(
                    request.StoreMembershipNumber))
            {
                return(GenerateErrorMessageWithMessage(
                           "Store membership number is not valid, it " +
                           "must be a multiple of 5!"));
            }

            // Return the output claim(s)
            return(new OkObjectResult(new ValidationResponseContent
            {
                StoreMembershipNumber =
                    request.StoreMembershipNumber.ToString()
            }));
        }
Ejemplo n.º 21
0
        private void SendEmail()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite _site = new SPSite(SPContext.Current.Site.ID, SPContext.Current.Site.Zone))
                {
                    using (SPWeb _web = _site.OpenWeb(SPContext.Current.Web.ID))
                    {
                        if (_web != null)
                        {
                            _site.AllowUnsafeUpdates = true;
                            _web.AllowUnsafeUpdates  = true;

                            if (!SPUtility.IsEmailServerSet(_web))
                            {
                                TemplateHelper helper = new TemplateHelper(_ctlPasswordRecovery.SuccessTemplateContainer);
                                helper.SetText("Success", "Password can not be reset since email server is not configutred for this sharepoint application.");
                                return;
                            }

                            PasswordRecovery prc             = _ctlPasswordRecovery;
                            MembershipUser currentUser       = Utils.BaseMembershipProvider(_web.Site).GetUser(prc.UserName, false);
                            MembershipRequest membershipitem = MembershipRequest.GetMembershipRequest(currentUser, _web);

                            membershipitem.PasswordQuestion = currentUser.PasswordQuestion;
                            membershipitem.Password         = currentUser.ResetPassword(prc.Answer);

                            if (!MembershipRequest.SendPasswordRecoveryEmail(membershipitem, _web))
                            {
                                TemplateHelper helper = new TemplateHelper(_ctlPasswordRecovery.SuccessTemplateContainer);
                                helper.SetText("Success", LocalizedString.GetString("FBAPackPasswordRecoveryWebPart", "ErrorSendingEmail"));
                            }
                        }
                    }
                }
            });
        }
            public async Task DeleteUnconfirmedOrganization()
            {
                // Arrange
                var member = new User("testUser")
                {
                    Key = Key++
                };
                var organization = new Organization("testOrganization")
                {
                    Key = Key++
                };

                var membership = new Membership()
                {
                    Organization = organization, Member = member
                };

                member.Organizations.Add(membership);
                organization.Members.Add(membership);

                var requestedMember = new User("testRequestedMember")
                {
                    Key = Key++
                };
                var memberRequest = new MembershipRequest()
                {
                    Organization = organization, NewMember = requestedMember
                };

                requestedMember.OrganizationRequests.Add(memberRequest);
                organization.MemberRequests.Add(memberRequest);

                PackageRegistration registration = new PackageRegistration();

                registration.Owners.Add(organization);

                Package p = new Package()
                {
                    Description = "TestPackage",
                    Key         = 1
                };

                p.PackageRegistration = registration;
                registration.Packages.Add(p);

                var testableService      = new DeleteAccountTestService(organization, registration);
                var deleteAccountService = testableService.GetDeleteAccountService();

                // Act
                var status = await deleteAccountService.
                             DeleteAccountAsync(
                    organization,
                    member,
                    commitAsTransaction : false,
                    orphanPackagePolicy : AccountDeletionOrphanPackagePolicy.KeepOrphans);

                // Assert
                Assert.True(status.Success);
                Assert.Null(testableService.User);
                Assert.Empty(registration.Owners);
                Assert.Empty(organization.SecurityPolicies);
                Assert.Empty(organization.ReservedNamespaces);
                Assert.Empty(testableService.DeletedAccounts);
                Assert.Single(testableService.SupportRequests);
                Assert.Empty(testableService.PackageOwnerRequests);
                Assert.True(testableService.HasDeletedOwnerScope);
                Assert.Single(testableService.AuditService.Records);

                var deleteRecord = testableService.AuditService.Records[0] as DeleteAccountAuditRecord;

                Assert.True(deleteRecord != null);
            }
Ejemplo n.º 23
0
 public Response CreateMemberAccount(MembershipRequest request)
 {
     throw new NotImplementedException();
 }
            public async Task DeleteOrganization(bool isPackageOrphaned, AccountDeletionOrphanPackagePolicy orphanPolicy)
            {
                // Arrange
                var member = new User("testUser")
                {
                    Key = Key++
                };
                var organization = new Organization("testOrganization")
                {
                    Key          = Key++,
                    EmailAddress = "*****@*****.**"
                };

                var membership = new Membership()
                {
                    Organization = organization, Member = member
                };

                member.Organizations.Add(membership);
                organization.Members.Add(membership);

                var requestedMember = new User("testRequestedMember")
                {
                    Key = Key++
                };
                var memberRequest = new MembershipRequest()
                {
                    Organization = organization, NewMember = requestedMember
                };

                requestedMember.OrganizationRequests.Add(memberRequest);
                organization.MemberRequests.Add(memberRequest);

                PackageRegistration registration = new PackageRegistration();

                registration.Owners.Add(organization);

                Package p = new Package()
                {
                    Description = "TestPackage",
                    Key         = 1
                };

                p.PackageRegistration = registration;
                registration.Packages.Add(p);

                var testableService      = new DeleteAccountTestService(organization, registration);
                var deleteAccountService = testableService.GetDeleteAccountService(isPackageOrphaned);

                // Act
                var status = await deleteAccountService.
                             DeleteAccountAsync(
                    organization,
                    member,
                    commitAsTransaction : false,
                    orphanPackagePolicy : orphanPolicy);

                // Assert
                if (orphanPolicy == AccountDeletionOrphanPackagePolicy.DoNotAllowOrphans && isPackageOrphaned)
                {
                    Assert.False(status.Success);
                    Assert.Equal(organization.Confirmed, organization.EmailAddress != null);
                    Assert.True(registration.Owners.Any(o => o.MatchesUser(organization)));
                    Assert.NotEmpty(organization.SecurityPolicies);
                    Assert.Empty(testableService.DeletedAccounts);
                    Assert.NotEmpty(testableService.PackageOwnerRequests);
                    Assert.Empty(testableService.AuditService.Records);
                    Assert.False(testableService.HasDeletedOwnerScope);
                    Assert.Empty(testableService.AuditService.Records);
                }
                else
                {
                    Assert.True(status.Success);
                    Assert.Null(organization.EmailAddress);
                    Assert.Equal(
                        orphanPolicy == AccountDeletionOrphanPackagePolicy.UnlistOrphans && isPackageOrphaned,
                        !registration.Packages.Single().Listed);
                    Assert.False(registration.Owners.Any(o => o.MatchesUser(organization)));
                    Assert.Empty(organization.SecurityPolicies);
                    Assert.Single(testableService.DeletedAccounts);
                    Assert.Empty(testableService.PackageOwnerRequests);
                    Assert.Single(testableService.AuditService.Records);
                    Assert.True(testableService.HasDeletedOwnerScope);

                    var deleteRecord = testableService.AuditService.Records[0] as DeleteAccountAuditRecord;
                    Assert.True(deleteRecord != null);
                }

                // Reserved namespaces and support requests are deleted before the request fails due to orphaned packages.
                // Because we are not committing as a transaction in these tests, they remain deleted.
                // In production, they would not be deleted because the transaction they were deleted in would fail.
                Assert.Empty(organization.ReservedNamespaces);
                Assert.Single(testableService.SupportRequests);
            }
Ejemplo n.º 25
0
 HookRegistry[] EnableMembership(MembershipRequest request);
Ejemplo n.º 26
0
 public int AddMembershipRequest(MembershipRequestCreateDto request, string email)
 {
     try
     {
         if (string.IsNullOrEmpty(request.Nickname))
         {
             throw new ArgumentException("Nickname cannot be empty");
         }
         var existingMember = _unitOfWork.Users.Get(t => t.Email == email).FirstOrDefault();
         if (existingMember == null)
         {
             throw new ArgumentException("User not found");
         }
         var club = _unitOfWork.Clubs.GetAsQueryable(t => t.Id == request.ClubId)
                    .Include(t => t.Administrators).ThenInclude(t => t.User)
                    .Include(t => t.MembershipRequests).SingleOrDefault();
         if (club == null)
         {
             throw new ArgumentException("Club not found");
         }
         if (club.MembershipRequests.Any(t => t.Nickname == request.Nickname))
         {
             throw new ArgumentException($"Membership request for nickname {request.Nickname} already exists");
         }
         var newRequest = new MembershipRequest
         {
             ClubId               = request.ClubId,
             UserId               = existingMember.Id,
             Created              = DateTimeOffset.UtcNow,
             LastActivity         = DateTimeOffset.UtcNow,
             Nickname             = request.Nickname,
             SelectedFromExisting = request.SelectedFromExisting,
             Status               = MembershipRequestStatus.Pending
         };
         club.MembershipRequests.Add(newRequest);
         var messageGuid = Guid.NewGuid();
         foreach (var administrator in club.Administrators)
         {
             administrator.User.InnerMessagesReceived.Add(new InnerMessage
             {
                 Status            = MessageStatus.Pending,
                 Body              = $"You have a new membership request in club {club.Title} from user with nickname {request.Nickname}",
                 Created           = DateTimeOffset.UtcNow,
                 Guid              = messageGuid,
                 OneResponseForAll = true,
                 LastActivity      = DateTimeOffset.UtcNow,
                 SentBySystem      = true,
                 Title             = "New Membership Request",
                 SenderType        = EntityType.System,
                 ReceiverType      = EntityType.User,
                 ReceiverId        = administrator.UserId
             });
         }
         _unitOfWork.Save();
         return(newRequest.Id);
     }
     catch (ArgumentException)
     {
         throw;
     }
     catch (Exception e)
     {
         _logger.LogError(e.Message);
         throw new Exception("Error while adding membership request. Please try a bit later");
     }
 }