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', '
')); - $fields->push($password = new ConfirmedPasswordField('Password', - 'Password' - )); - - $password->setCanBeEmpty(true); + $fields->push(new LiteralField('changepassword','Click here to change your password')); // Create action diff --git a/registration/code/EditProfilePage.php b/registration/code/EditProfilePage.php index edef584..66ef9b7 100755 --- a/registration/code/EditProfilePage.php +++ b/registration/code/EditProfilePage.php @@ -225,11 +225,6 @@ class EditProfilePage_Controller extends Page_Controller } } - function FoundationMember() - { - // see if the member is in the foundation group - if (Member::currentUser() && Member::currentUser()->inGroup('foundation-members')) return TRUE; - } function CompanyAdmin() { @@ -339,7 +334,7 @@ class EditProfilePage_Controller extends Page_Controller } // Save an edited candidate - function save($data, $form) + function saveCandidateApplicationForm($data, $form) { @@ -408,18 +403,19 @@ class EditProfilePage_Controller extends Page_Controller $form->saveInto($Candidate); $Candidate->write(); - $this->setMessage('Success', 'Your edits have been saved but you will need to provide full answers to all these questions to be eligible as a candidate.'); + $form->clearMessage(); + $form->sessionMessage( "Your edits have been saved but you will need to provide full answers to all these questions to be eligible as a candidate.","bad"); $this->redirectBack(); return; } $Candidate->HasAcceptedNomination = TRUE; $Candidate->write(); - - $this->setMessage('Success', 'Congratulations. You have accepted your nomination as a candidate. Good luck in the election!'); + $form->clearMessage(); $this->redirect($this->Link() . 'election/'); } else { - $this->setMessage('Error', 'There was an error saving your edits.'); + $form->clearMessage(); + $form->sessionMessage('There was an error saving your edits.',"bad"); $this->redirectBack(); } diff --git a/registration/javascript/edit.profile.page.js b/registration/javascript/edit.profile.page.js index 751c107..2223a77 100755 --- a/registration/javascript/edit.profile.page.js +++ b/registration/javascript/edit.profile.page.js @@ -65,8 +65,6 @@ jQuery(document).ready(function($) { City:{required: true}, State:{required: true}, Postcode:{required: true}, - 'Password[_Password]': {required: true,minlength: 5}, - 'Password[_ConfirmPassword]': {required: true,minlength: 5,equalTo: '#Password-_Password'}, 'Affiliations':{checkAffiliations:true}, 'Gender':{required:true} }, diff --git a/registration/templates/Layout/EditProfilePage_CandidateApplication.ss b/registration/templates/Layout/EditProfilePage_CandidateApplication.ss index 979c737..ed72f8b 100644 --- a/registration/templates/Layout/EditProfilePage_CandidateApplication.ss +++ b/registration/templates/Layout/EditProfilePage_CandidateApplication.ss @@ -1,18 +1,12 @@
- <% require javascript(sapphire/thirdparty/tinymce/tiny_mce.js) %> - <% require javascript(themes/openstack/javascript/simple-tinymce.js) %> - + <% require javascript(framework/thirdparty/tinymce/tiny_mce.js) %> + <% require javascript(themes/openstack/javascript/simple-tinymce.js) %> <% require themedCSS(profile-section) %> - - - <% if FoundationMember %> - + <% if CurrentMember.isFoundationMember %>

Accept Nomination

To accept nominations and be listed as a candidate for the OpenStack election, please answer the questions below.

Candidate Application Form

$CandidateApplicationForm - - <% else %>

In order to edit your community profile, you will first need to login as a member. Don't have an account? Join The Foundation

Login 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 @@
$SetCurrentTab(2) - <% require themedCSS(profile-section) %> - -

$Title

- - - <% if FoundationMember %> +

$Title

+ <% if CurrentMember.isFoundationMember %> <% include ProfileNav %> @@ -66,4 +62,5 @@

In order to edit your community profile, you will first need to login as a member. Don't have an account? Join The Foundation

Login Join The Foundation

<% end_if %> -
+ + diff --git a/registration/templates/Layout/EditProfilePage_speaker.ss b/registration/templates/Layout/EditProfilePage_speaker.ss index 328f677..835168c 100644 --- a/registration/templates/Layout/EditProfilePage_speaker.ss +++ b/registration/templates/Layout/EditProfilePage_speaker.ss @@ -1,31 +1,25 @@
- - $SetCurrentTab(7) - - <% require themedCSS(profile-section) %> - -

$Title

- - - <% if CurrentMember %> - <% if Saved %> - -
-

Your Profile has been saved!

-
- - - <% end_if %> - - <% include ProfileNav %> - - - $EditSpeakerProfileForm - - - - <% else %> -

In order to edit your community profile, you will first need to login as a member. Don't have an account? Join The Foundation

-

Login Join The Foundation

- <% end_if %> -
\ No newline at end of file + <% require javascript(framework/thirdparty/tinymce/tiny_mce.js) %> + <% require javascript(themes/openstack/javascript/simple-tinymce.js) %> + $SetCurrentTab(7) + <% require themedCSS(profile-section) %> +

$Title

+ <% if CurrentMember %> + <% if Saved %> + +
+

Your Profile has been saved!

+
+ <% end_if %> + <% include ProfileNav %> + $EditSpeakerProfileForm + <% else %> +

In order to edit your community profile, you will first need to login as a member. Don't have an account? Join The Foundation

+ +

Login 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 @@

class="active"<% end_if %> >Your Details -<% if FoundationMember %> +<% if CurrentMember.isFoundationMember %> class="active"<% end_if %> >Election <% end_if %> class="active"<% end_if %> >Legal Agreements diff --git a/themes/openstack/templates/Layout/Includes/CurrentUserInfoBox.ss b/themes/openstack/templates/Layout/Includes/CurrentUserInfoBox.ss new file mode 100644 index 0000000..e69de29 diff --git a/themes/openstack/templates/Layout/MemberListPage_confirmNomination.ss b/themes/openstack/templates/Layout/MemberListPage_confirmNomination.ss index de6f14a..4d7bf92 100644 --- a/themes/openstack/templates/Layout/MemberListPage_confirmNomination.ss +++ b/themes/openstack/templates/Layout/MemberListPage_confirmNomination.ss @@ -4,15 +4,17 @@

Please confirm your nomination

-

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 %> -

You have already nominated $Candidate.FirstName $Candidate.Surname.

-

See Nominations See All Members

- + <% with Candidate %> +

You have already nominated $FirstName $Surname.

+ <% end_with %> +

See Nominations See All Members

<% else_if LimitExceeded %>

This candidate has already received 10 nominations.

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.