コード例 #1
0
 function StartSurvey($data, $form)
 {
     //Check for existing member email address
     if ($member = Member::get()->filter('Email', Convert::raw2sql($data['Email']))->first()) {
         //Set error message
         $form->AddErrorMessage('Email', "Sorry, that email address already exists. Please choose another or login with that email.", 'bad');
         //Set form data from submitted values
         Session::set("FormInfo.Form_DeploymentSurveyRegistrationForm.data", $data);
         //Return back to form
         return Controller::curr()->redirectBack();
     }
     //Otherwise create new member and log them in
     $Member = new Member();
     $form->saveInto($Member);
     $Member->write();
     //Find or create the 'user' group
     if (!($userGroup = Group::get()->filter('Code', 'users')->first())) {
         $userGroup = new Group();
         $userGroup->Code = "users";
         $userGroup->Title = "Users";
         $userGroup->Write();
         $Member->Groups()->add($userGroup);
     }
     //Add member to user group
     $Member->Groups()->add($userGroup);
     $BackURL = Controller::curr()->Link('AboutYou');
     return OpenStackIdCommon::loginMember($Member, $BackURL);
 }
コード例 #2
0
 /**
  * @param array $data
  * @return SS_HTTPResponse|void
  */
 function doChangePassword(array $data)
 {
     try {
         $token = Session::get('AutoLoginHash');
         $member = $this->password_manager->changePassword($token, @$data['NewPassword1'], @$data['NewPassword2']);
         Session::clear('AutoLoginHash');
         $back_url = isset($_REQUEST['BackURL']) ? $_REQUEST['BackURL'] : '/';
         return OpenStackIdCommon::loginMember($member, $back_url);
     } catch (InvalidResetPasswordTokenException $ex1) {
         Session::clear('AutoLoginHash');
         Controller::curr()->redirect('login');
     } catch (EmptyPasswordException $ex2) {
         $this->clearMessage();
         $this->sessionMessage(_t('Member.EMPTYNEWPASSWORD', "The new password can't be empty, please try again"), "bad");
         Controller::curr()->redirectBack();
     } catch (PasswordMismatchException $ex3) {
         $this->clearMessage();
         $this->sessionMessage(_t('Member.ERRORNEWPASSWORD', "You have entered your new password differently, try again"), "bad");
         Controller::curr()->redirectBack();
     } catch (InvalidPasswordException $ex4) {
         $this->clearMessage();
         $this->sessionMessage(sprintf(_t('Member.INVALIDNEWPASSWORD', "We couldn't accept that password: %s"), nl2br("\n" . $ex4->getMessage())), "bad");
         Controller::curr()->redirectBack();
     }
 }
コード例 #3
0
 function StartSurvey($data, $form)
 {
     try {
         $data = SQLDataCleaner::clean($data);
         $data['MembershipType'] = 'community';
         Session::set("FormInfo.{$form->FormName()}.data", $data);
         $profile_page = EditProfilePage::get()->first();
         $member = $this->member_manager->registerMobile($data, new MemberRegistrationSenderService());
         //Get profile page
         if (!is_null($profile_page)) {
             //Redirect to profile page with success message
             Session::clear("FormInfo.{$form->FormName()}.data");
             $request = Controller::curr()->getRequest();
             $back_url = $request->postVar('BackURL');
             $link = $profile_page->Link('?success=1');
             if (!empty($back_url)) {
                 $link .= "&BackURL=" . $back_url;
             }
             return OpenStackIdCommon::loginMember($member, $link);
         }
     } catch (EntityValidationException $ex1) {
         Form::messageForForm($form->FormName(), $ex1->getMessage(), 'bad');
         //Return back to form
         SS_Log::log($ex1->getMessage(), SS_Log::WARN);
         return Controller::curr()->redirectBack();
     } catch (Exception $ex) {
         Form::messageForForm($form->FormName(), "There was an error with your request, please contact your admin.", 'bad');
         //Return back to form
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         return Controller::curr()->redirectBack();
     }
 }
コード例 #4
0
 /**
  * @param Controller $controller
  * @param string $back_url
  * @return Form
  */
 public static function buildLoginForm(Controller $controller, $back_url = '')
 {
     if (!defined('OPENSTACKID_ENABLED') || OPENSTACKID_ENABLED == false) {
         $form = MemberAuthenticator::get_login_form($controller);
         return $form;
     } else {
         $back_url = OpenStackIdCommon::cleanBackUrl($back_url);
         $form = new Form($controller, 'OpenStackIdLoginForm', $fields = new FieldList(), $actions = new FieldList(array(new FormAction('dologin', _t('Member.BUTTONLOGIN', "Log in")))));
         $form->addExtraClass('form-fieldless');
         $form->setFormAction("/Security/login?BackURL={$back_url}");
         $form->setFormMethod('post');
         return $form;
     }
 }
コード例 #5
0
 public function init()
 {
     $this->top_section = 'short';
     //or full
     parent::init();
     if (!Member::currentUser()) {
         return OpenStackIdCommon::doLogin();
     }
     Requirements::javascript("summit/bower_components/sweetalert/lib/sweet-alert.js");
     Requirements::css("summit/bower_components/sweetalert/lib/sweet-alert.css");
     //Requirements::javascript('//tinymce.cachefly.net/4.3/tinymce.min.js');
     Requirements::javascript('summit/javascript/summitapp-review.js');
     Requirements::javascript('marketplace/code/ui/frontend/js/star-rating.min.js');
     Requirements::css("marketplace/code/ui/frontend/css/star-rating.min.css");
 }
コード例 #6
0
 public function init()
 {
     parent::init();
     if (!Member::currentUser()) {
         return OpenStackIdCommon::doLogin();
     }
     if (!Permission::check("ADMIN_SUMMIT_APP_FRONTEND_ADMIN")) {
         Security::permissionFailure($this);
     }
     Requirements::css("themes/openstack/bower_assets/bootstrap/dist/css/bootstrap.min.css");
     Requirements::css("themes/openstack/bower_assets/fontawesome/css/font-awesome.min.css");
     Requirements::css('//fonts.googleapis.com/css?family=Open+Sans:300,400,700');
     Requirements::css("themes/openstack/css/combined.css");
     Requirements::css("themes/openstack/css/navigation_menu.css");
     Requirements::css("themes/openstack/css/dropdown.css");
     Requirements::css('themes/openstack/css/chosen.css');
     Requirements::css('summit/bower_components/bootstrap-tagsinput/dist/bootstrap-tagsinput.css');
     Requirements::css("themes/openstack/javascript/datetimepicker/jquery.datetimepicker.css");
     Requirements::css('summit/css/summit-admin.css');
     Requirements::javascript("themes/openstack/bower_assets/jquery/dist/jquery.min.js");
     Requirements::javascript("themes/openstack/bower_assets/jquery-migrate/jquery-migrate.min.js");
     Requirements::javascript("themes/openstack/bower_assets/bootstrap/dist/js/bootstrap.min.js");
     Requirements::javascript('themes/openstack/javascript/chosen.jquery.min.js');
     Requirements::javascript('themes/openstack/bower_assets/moment/min/moment.min.js');
     Requirements::javascript("themes/openstack/javascript/datetimepicker/jquery.datetimepicker.js");
     Requirements::javascript('themes/openstack/javascript/urlfragment.jquery.js');
     Requirements::javascript("themes/openstack/bower_assets/jquery-ui/jquery-ui.min.js");
     Requirements::javascript("themes/openstack/javascript/jquery-ui-bridge.js");
     if (Director::isLive()) {
         Requirements::javascript("themes/openstack/bower_assets/jquery-validate/dist/jquery.validate.min.js");
         Requirements::javascript("themes/openstack/bower_assets/jquery-validate/dist/additional-methods.min.js");
     } else {
         Requirements::javascript("themes/openstack/bower_assets/jquery-validate/dist/jquery.validate.js");
         Requirements::javascript("themes/openstack/bower_assets/jquery-validate/dist/additional-methods.js");
     }
     Requirements::javascript('summit/javascript/bootstrap-dropdown.js');
     Requirements::javascript('summit/bower_components/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js');
     Requirements::javascript('themes/openstack/javascript/jquery.serialize.js');
     $this->event_repository = new SapphireSummitEventRepository();
     $this->promocode_repository = new SapphireSummitRegistrationPromoCodeRepository();
     $this->eventbrite_attendee_repository = new SapphireEventbriteAttendeeRepository();
 }
コード例 #7
0
 public function BackUrl()
 {
     return OpenStackIdCommon::getRedirectBackUrl();
 }
コード例 #8
0
 function index()
 {
     try {
         $member = Member::currentUser();
         if ($member) {
             // user is already logged in
             return $this->redirect(OpenStackIdCommon::getRedirectBackUrl());
         }
         $consumer = Injector::inst()->get('MyOpenIDConsumer');
         $query = Auth_OpenID::getQuery();
         $message = Auth_OpenID_Message::fromPostArgs($query);
         $nonce = $message->getArg(Auth_OpenID_OPENID2_NS, 'response_nonce');
         list($timestamp, $salt) = Auth_OpenID_splitNonce($nonce);
         $claimed_id = $message->getArg(Auth_OpenID_OPENID2_NS, 'claimed_id');
         error_log(sprintf('OpenStackIdAuthenticator : id %s - salt %s - timestamp %s', $claimed_id, $salt, $timestamp));
         // Complete the authentication process using the server's response.
         $response = $consumer->complete(OpenStackIdCommon::getReturnTo());
         if ($response->status == Auth_OpenID_CANCEL) {
             error_log('OpenStackIdAuthenticator : Auth_OpenID_CANCEL');
             SS_Log::log('OpenStackIdAuthenticator : Auth_OpenID_CANCEL', SS_Log::WARN);
             throw new Exception('The verification was cancelled. Please try again.');
         } else {
             if ($response->status == Auth_OpenID_FAILURE) {
                 error_log('OpenStackIdAuthenticator : Auth_OpenID_FAILURE');
                 SS_Log::log('OpenStackIdAuthenticator : Auth_OpenID_FAILURE', SS_Log::WARN);
                 throw new Exception("The OpenID authentication failed.");
             } else {
                 if ($response->status == Auth_OpenID_SUCCESS) {
                     error_log('OpenStackIdAuthenticator : Auth_OpenID_SUCCESS');
                     $openid = $response->getDisplayIdentifier();
                     $openid = OpenStackIdCommon::escape($openid);
                     if ($response->endpoint->canonicalID) {
                         $openid = escape($response->endpoint->canonicalID);
                     }
                     //get user info from openid response
                     $member = null;
                     list($email, $full_name) = $this->getUserProfileInfo($response);
                     if (!is_null($email)) {
                         //try to get user by email
                         $member = $this->member_repository->findByEmail($email);
                     }
                     if (!$member) {
                         // or by openid
                         $member = Member::get()->filter('IdentityURL', $openid)->first();
                     }
                     if ($member) {
                         $result = $member->canLogIn();
                         if ($result->valid()) {
                             $member->setIdentityUrl($openid);
                             $member->write();
                             $member->LogIn(true);
                             return $this->redirect(OpenStackIdCommon::getRedirectBackUrl());
                         }
                         throw new Exception("Inactive User!");
                     }
                     throw new Exception("The OpenID authentication failed: can not find user " . $openid);
                 }
             }
         }
     } catch (Exception $ex) {
         Session::set("Security.Message.message", $ex->getMessage());
         Session::set("Security.Message.type", "bad");
         SS_Log::log($ex, SS_Log::WARN);
         return $this->redirect("Security/badlogin");
     }
 }
コード例 #9
0
 function doRegister($data, $form)
 {
     if (!isset($data["Affiliations"]) || empty($data["Affiliations"])) {
         //Set error message
         $form->AddErrorMessage('Affiliations', "Sorry, You must at least enter one valid Affiliation.", 'bad');
         //Set form data from submitted values
         Session::set("FormInfo.Form_RegistrationForm.data", $data);
         //Return back to form
         return $this->redirectBack();
     }
     $new_affiliations = json_decode($data["Affiliations"]);
     //Check for existing member email address
     if ($member = Member::get()->filter('Email', Convert::raw2sql($data['Email']))->first()) {
         //Set error message
         $form->AddErrorMessage('Email', "Sorry, that email address already exists. Please choose another.", 'bad');
         //Set form data from submitted values
         Session::set("FormInfo.Form_RegistrationForm.data", $data);
         //Return back to form
         return $this->redirectBack();
     }
     //Otherwise create new member and log them in
     $Member = new Member();
     $form->saveInto($Member);
     if (isset($data['Gender'])) {
         $Gender = $data['Gender'];
         if ($Gender != 'Male' && $Gender != 'Female' && $Gender != 'Prefer not to say') {
             $Member->Gender = Convert::raw2sql($data['GenderSpecify']);
         }
     }
     $Member->write();
     if ($data['MembershipType'] == 'foundation') {
         $Member->upgradeToFoundationMember();
     } else {
         $Member->convert2SiteUser();
     }
     //Find or create the 'user' group
     if (!($userGroup = Group::get()->filter('Code', 'users')->first())) {
         $userGroup = new Group();
         $userGroup->Code = "users";
         $userGroup->Title = "Users";
         $userGroup->Write();
         $Member->Groups()->add($userGroup);
     }
     //Add member to user group
     $Member->Groups()->add($userGroup);
     foreach ($new_affiliations as $key => $newAffiliation) {
         $dbAffiliation = new Affiliation();
         $org_name = Convert::raw2sql($newAffiliation->OrgName);
         $org_name = trim($org_name);
         AffiliationController::Save($dbAffiliation, $newAffiliation, $org_name, $Member);
     }
     PublisherSubscriberManager::getInstance()->publish('new_user_registered', array($Member->ID));
     //Get profile page
     if ($ProfilePage = EditProfilePage::get()->first()) {
         //send Thank you email
         $config = SiteConfig::current_site_config();
         if ($config->RegistrationSendMail && !empty($config->RegistrationFromMessage) && !empty($config->RegistrationSubjectMessage) && !empty($config->RegistrationHTMLMessage) && !empty($config->RegistrationPlainTextMessage)) {
             $registration_email = new CustomEmail($config->RegistrationFromMessage, $Member->Email, $data['MembershipType'] == 'foundation' ? 'Thank you for becoming an OpenStack Foundation Member' : 'Thank you for becoming an OpenStack Community Member', $config->RegistrationHTMLMessage, $config->RegistrationPlainTextMessage);
             $registration_email->send();
         }
         //Redirect to profile page with success message
         return OpenStackIdCommon::loginMember($member, $ProfilePage->Link('?success=1'));
     }
 }
コード例 #10
0
 public function alreadyRegistered()
 {
     if (Member::currentUser()) {
         $this->redirect($this->AlreadyRegisteredURL);
     }
     OpenStackIdCommon::doLogin($this->Link('already-registered'));
 }
コード例 #11
0
 function doRegister($data, $form)
 {
     try {
         $data = SQLDataCleaner::clean($data, $non_check_keys = array('HiddenAffiliations'));
         Session::set("FormInfo.{$form->FormName()}.data", $data);
         $profile_page = EditProfilePage::get()->first();
         $member = $this->member_manager->register($data, $profile_page, new MemberRegistrationSenderService());
         //Get profile page
         if (!is_null($profile_page)) {
             //Redirect to profile page with success message
             Session::clear("FormInfo.{$form->FormName()}.data");
             return OpenStackIdCommon::loginMember($member, $profile_page->Link('?success=1'));
         }
     } catch (EntityValidationException $ex1) {
         Form::messageForForm('HoneyPotForm_RegistrationForm', $ex1->getMessage(), 'bad');
         //Return back to form
         SS_Log::log($ex1->getMessage(), SS_Log::ERR);
         return $this->redirectBack();
     } catch (Exception $ex) {
         Form::messageForForm('HoneyPotForm_RegistrationForm', "There was an error with your request, please contact your admin.", 'bad');
         //Return back to form
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         return $this->redirectBack();
     }
 }
コード例 #12
0
 /**
  * Handles the registration. Validates and creates the member, then redirects
  * to the appropriate place
  *  
  * @param  array $data
  * @param  BootstrapForm $form
  * @return SSViewer
  */
 public function doRegister($data, $form)
 {
     try {
         Session::set("FormInfo.{$form->getName()}.data", $data);
         $member = Member::get()->filter('Email', $data['Email'])->first();
         if ($member) {
             $form->sessionMessage('Bah! We\'ve already got a user with that email.', 'bad');
             return $this->redirectBack();
         }
         if ($data['Password'] != $data['Password_confirm']) {
             $form->sessionMessage('Passwords do not match.', 'bad');
             return $this->redirectBack();
         }
         $member = Member::create(array('FirstName' => $data['FirstName'], 'Surname' => $data['Surname'], 'Email' => $data['Email'], 'Password' => $data['Password']));
         $member->write();
         if (!empty($data[SpeakerRegistrationRequest::ConfirmationTokenParamName])) {
             $speaker_registration_token = $data[SpeakerRegistrationRequest::ConfirmationTokenParamName];
             $this->speaker_registration_request_manager->confirm($speaker_registration_token, $member);
         }
         $member->addToGroupByCode('speakers');
         $member->sendWelcomeEmail();
         Session::clear("FormInfo.{$form->getName()}.data");
         if ($data['BackURL']) {
             $redirect = HTTP::setGetVar('welcome', 1, $data['BackURL']);
             return OpenStackIdCommon::loginMember($member, $redirect);
         }
         $form->sessionMessage('Awesome! You should receive an email shortly.', 'good');
         return OpenStackIdCommon::loginMember($member, $this->redirectBackUrl());
     } catch (Exception $ex) {
         SS_Log::log($ex, SS_Log::WARN);
         return $this->httpError(404, $ex->getMessage());
     }
 }
コード例 #13
0
 /**
  * Handles the registration. Validates and creates the member, then redirects
  * to the appropriate place
  *  
  * @param  array $data
  * @param  BootstrapForm $form
  * @return SSViewer
  */
 public function doRegister($data, $form)
 {
     try {
         $back_url = Session::get('BackURL');
         Session::set("FormInfo.{$form->getName()}.data", $data);
         $data = SQLDataCleaner::clean($data);
         $profile_page = EditProfilePage::get()->first();
         $speaker_registration_token = Session::get(SpeakerRegistrationRequest::ConfirmationTokenParamName);
         if (!empty($speaker_registration_token)) {
             $data[SpeakerRegistrationRequest::ConfirmationTokenParamName] = $speaker_registration_token;
         }
         $member = $this->member_manager->registerSpeaker($data, new MemberRegistrationSenderService());
         //Get profile page
         if (!is_null($profile_page)) {
             //Redirect to profile page with success message
             Session::clear("FormInfo.{$form->FormName()}.data");
             if ($back_url) {
                 $redirect = HTTP::setGetVar('welcome', 1, $back_url);
                 return OpenStackIdCommon::loginMember($member, $redirect);
             }
             $form->sessionMessage('Awesome! You should receive an email shortly.', 'good');
             Session::clear(SpeakerRegistrationRequest::ConfirmationTokenParamName);
             Session::clear('BackURL');
             return OpenStackIdCommon::loginMember($member, $this->redirectBackUrl());
         }
     } catch (EntityValidationException $ex1) {
         Form::messageForForm($form->FormName(), $ex1->getMessage(), 'bad');
         //Return back to form
         SS_Log::log($ex1->getMessage(), SS_Log::WARN);
         return $this->redirectBack();
     } catch (Exception $ex) {
         Form::messageForForm($form->FormName(), "There was an error with your request, please contact your admin.", 'bad');
         //Return back to form
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         return $this->redirectBack();
     }
 }
コード例 #14
0
 function doRegister($data, $form)
 {
     //Check for existing member email address
     if ($member = Member::get()->filter('Email', Convert::raw2sql($data['Email']))->first()) {
         //Set error message
         $form->AddErrorMessage('Email', "Sorry, that email address already exists. Please choose another.", 'bad');
         //Set form data from submitted values
         Session::set("FormInfo.SafeXSSForm_Form.data", $data);
         //Return back to form
         return $this->redirectBack();
     }
     //Otherwise create new member and log them in
     $Member = new Member();
     $form->saveInto($Member);
     $Member->write();
     //Find or create the 'user' group
     if (!($userGroup = Group::get()->filter('Code', 'presentation-voters')->first())) {
         $userGroup = new Group();
         $userGroup->Code = "presentation-voters";
         $userGroup->Title = "Presentation Voters";
         $userGroup->Write();
         $Member->Groups()->add($userGroup);
     }
     //Add member to user group
     $Member->Groups()->add($userGroup);
     //Get current voting page and redirect there
     if ($VotingPage = PresentationVotingPage::get()->first()) {
         $BackURL = Session::get('BackURL');
         if ($BackURL) {
             $BackURL = $VotingPage->Link() . 'Presentation/' . $BackURL;
         } else {
             $BackURL = $VotingPage->Link();
         }
     }
     return OpenStackIdCommon::loginMember($Member, $BackURL);
 }