diff --git a/change_password/code/model/PasswordManager.php b/change_password/code/model/PasswordManager.php index 3a55ad9..61dfcf9 100644 --- a/change_password/code/model/PasswordManager.php +++ b/change_password/code/model/PasswordManager.php @@ -48,8 +48,11 @@ final class PasswordManager { * @throws PasswordMismatchException */ public function changePassword($token, $password, $password_confirmation){ - if(empty($token)) throw new InvalidResetPasswordTokenException; - $member = Member::member_from_autologinhash($token); + $member = Member::currentUser(); + if(!$member) { + if (empty($token)) throw new InvalidResetPasswordTokenException; + $member = Member::member_from_autologinhash($token); + } if(!$member) throw new InvalidResetPasswordTokenException; if(empty($password)) throw new EmptyPasswordException; if($password !== $password_confirmation) throw new PasswordMismatchException; diff --git a/change_password/code/ui/CustomChangePasswordForm.php b/change_password/code/ui/CustomChangePasswordForm.php index 524ed18..eee7cf8 100644 --- a/change_password/code/ui/CustomChangePasswordForm.php +++ b/change_password/code/ui/CustomChangePasswordForm.php @@ -48,7 +48,7 @@ final class CustomChangePasswordForm extends ChangePasswordForm { } catch(InvalidResetPasswordTokenException $ex1){ Session::clear('AutoLoginHash'); - Controller::curr()->redirect('loginpage'); + Controller::curr()->redirect('login'); } catch(EmptyPasswordException $ex2){ $this->clearMessage(); diff --git a/change_password/code/ui/CustomPasswordController.php b/change_password/code/ui/CustomPasswordController.php index aa19e9b..9b5f05e 100644 --- a/change_password/code/ui/CustomPasswordController.php +++ b/change_password/code/ui/CustomPasswordController.php @@ -63,11 +63,25 @@ class CustomPasswordController extends Security { 'Form' => $this->ChangePasswordForm(), )); } - else{ + else if(isset($_REQUEST['t']) && isset($_REQUEST['m'])){ $new_hash = $this->password_manager->verifyToken((int)@$_REQUEST['m'], @$_REQUEST['t']); Session::set('AutoLoginHash', $new_hash); return $this->redirect($this->Link('changepassword')); } + else if(Member::currentUser()) { + // Logged in user requested a password change form. + $customisedController = $controller->customise(array( + 'Content' => '
' + . _t('Security.CHANGEPASSWORDBELOW', 'You can change your password below.') . '
', + 'Form' => $this->ChangePasswordForm())); + } + else{ + self::permissionFailure( + $this, + _t('Security.ERRORPASSWORDPERMISSION', 'You must be logged in in order to change your password!') + ); + return; + } } catch(InvalidPasswordResetLinkException $ex1){ $customisedController = $controller->customise( diff --git a/openstack/code/CandidateApplicationForm.php b/openstack/code/CandidateApplicationForm.php index 415aa74..91dc1e2 100644 --- a/openstack/code/CandidateApplicationForm.php +++ b/openstack/code/CandidateApplicationForm.php @@ -25,7 +25,7 @@ class CandidateApplicationForm extends HoneyPotForm { new TextAreaField('TopPriority',"What do you think the top priority of the Board should be in 2015?") ); - $actionButton = new FormAction('save', 'Save Candidate Application'); + $actionButton = new FormAction('saveCandidateApplicationForm', 'Save Candidate Application'); //$actionButton->addExtraClass('btn green-btn'); $actions = new FieldList( diff --git a/openstack/code/MemberListPage.php b/openstack/code/MemberListPage.php index 4b04031..48f6943 100644 --- a/openstack/code/MemberListPage.php +++ b/openstack/code/MemberListPage.php @@ -141,7 +141,7 @@ class MemberListPage_Controller extends Page_Controller // Check to see if the candidate ID is numeric and if the person is logged in if ($this->validateNomation($CandidateID) == 'VALID') { - $Nominee = Member::get()->filter(array('ID' => $CandidateID)); + $Nominee = Member::get()->filter(array('ID' => $CandidateID))->first(); $results["Success"] = TRUE; $results["Candidate"] = $Nominee; $results["NominateLink"] = $this->Link() . "saveNomination/" . $CandidateID; @@ -149,7 +149,7 @@ class MemberListPage_Controller extends Page_Controller } elseif ($this->validateNomation($CandidateID) == 'ALREADY NOMINATED') { - $Nominee = Member::get()->filter(array('ID' => $CandidateID)); + $Nominee = Member::get()->filter(array('ID' => $CandidateID))->first(); $CurrentElection = $this->CurrentElection(); @@ -162,7 +162,7 @@ class MemberListPage_Controller extends Page_Controller } elseif ($this->validateNomation($CandidateID) == 'LIMIT EXCEEDED') { - $Nominee = Member::get()->filter(array('ID' => $CandidateID)); + $Nominee = Member::get()->filter(array('ID' => $CandidateID))->first(); $results["Success"] = FALSE; $results["LimitExceeded"] = TRUE; @@ -223,7 +223,7 @@ class MemberListPage_Controller extends Page_Controller // 6. Make sure that the person nominating is a foundation member $CurrentMember = Member::currentUser(); - If (!$CurrentMember->inGroup(5, TRUE)) { + If (!$CurrentMember->isFoundationMember()) { return 'INVALID VOTER'; } @@ -235,7 +235,8 @@ class MemberListPage_Controller extends Page_Controller function saveNomination() { - $CandidateID = $this->request->param("OtherID"); + // Grab candidate ID from the URL + $CandidateID = $this->request->param("ID"); $NominationStatus = $this->validateNomation($CandidateID); // Check to see if this is a valid nomination @@ -275,30 +276,20 @@ class MemberListPage_Controller extends Page_Controller fclose($file); // Email the member - // In dev and testing, send the nomination emails to the person who did the nomination $To = $currentMember->Email; - // In live mode, send the email to the candidate if (Director::isLive()) $To = $Candidate->Member()->Email; - $Subject = "You have been nominated in the " . $CurrentElection->Title; $email = EmailFactory::getInstance()->buildEmail(CANDIDATE_NOMINATION_FROM_EMAIL, $To, $Subject); $email->setTemplate('NominationEmail'); - // Gather Data to send to template $data["Candidate"] = $Candidate; $data["Election"] = $CurrentElection; - - $email->populateTemplate($data); $email->send(); - - $this->setMessage('Success', "You've just nominated " . $Candidate->Member()->FirstName . ' for the OpenStack Board.'); - $this->redirect('/community/members/candidateStats/' . $Candidate->Member()->ID); - - + $this->redirect($this->Link('candidateStats/' . $Candidate->Member()->ID)); } elseif ($NominationStatus = 'ALREADY NOMINATED') { $this->setMessage('Error', "Oops, you have already nominated this person."); @@ -350,7 +341,7 @@ class MemberListPage_Controller extends Page_Controller { // Grab candidate ID from the URL - $CandidateID = $this->request->param("OtherID"); + $CandidateID = $this->request->param("ID"); // Check to see if the candidate is valid if (is_numeric($CandidateID) && $this->findMember($CandidateID)) { diff --git a/registration/code/EditProfileForm.php b/registration/code/EditProfileForm.php index fdcf166..f818f30 100644 --- a/registration/code/EditProfileForm.php +++ b/registration/code/EditProfileForm.php @@ -211,11 +211,7 @@ class EditProfileForm extends SafeXSSForm { $fields->push(new LiteralField('break', 'To accept nominations and be listed as a candidate for the OpenStack election, please answer the questions below.
In order to edit your community profile, you will first need to login as a member. Don't have an account? Join The Foundation
diff --git a/registration/templates/Layout/EditProfilePage_election.ss b/registration/templates/Layout/EditProfilePage_election.ss index 9623b22..f542f67 100644 --- a/registration/templates/Layout/EditProfilePage_election.ss +++ b/registration/templates/Layout/EditProfilePage_election.ss @@ -1,12 +1,8 @@In order to edit your community profile, you will first need to login as a member. Don't have an account? Join The Foundation
<% end_if %> -Your Profile has been saved!
-In order to edit your community profile, you will first need to login as a member. Don't have an account? Join The Foundation
- - <% end_if %> -Your Profile has been saved!
+In order to edit your community profile, you will first need to login as a member. Don't have an account? Join The Foundation
+ + + <% end_if %> + \ No newline at end of file diff --git a/registration/templates/Layout/Includes/ProfileNav.ss b/registration/templates/Layout/Includes/ProfileNav.ss index a8f9d2e..3d9a184 100644 --- a/registration/templates/Layout/Includes/ProfileNav.ss +++ b/registration/templates/Layout/Includes/ProfileNav.ss @@ -3,7 +3,7 @@Are you sure you would officially like to nominate $Candidate.FirstName $Candidate.Surname to the OpenStack Board?
+Are you sure you would officially like to nominate $Candidate.FirstName $Candidate.Surname to the OpenStack Board?
+Yes, Nominate $Candidate.FirstName No
<% else %> <% if NominatedByMe %> -See Nominations See All Members
- + <% with Candidate %> +See Nominations See All Members
<% else_if LimitExceeded %>That's all the nominations that are required to appear on the election ballot. You may want to nominate someone else who you think would be a good candidate.