Skip to content

Commit

Permalink
Merge branch 'hotfix/sso-name-clash' of github.com:vanilla/vanilla
Browse files Browse the repository at this point in the history
  • Loading branch information
linc committed Jul 19, 2015
2 parents e5a9a4c + 965bc38 commit e24fcd4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions applications/dashboard/controllers/class.entrycontroller.php
Expand Up @@ -380,6 +380,7 @@ public function connect($Method) {
$this->addJsFile('entry.js');
$this->View = 'connect';
$IsPostBack = $this->Form->isPostBack() && $this->Form->getFormValue('Connect', null) !== null;
$UserSelect = $this->Form->getFormValue('UserSelect');

if (!$IsPostBack) {
// Here are the initial data array values. that can be set by a plugin.
Expand Down Expand Up @@ -517,6 +518,10 @@ public function connect($Method) {
$UserModel->SQL->orWhere('Email', $this->Form->getFormValue('Email'));
$Search = true;
}
if (is_numeric($UserSelect)) {
$UserModel->SQL->orWhere('UserID', $UserSelect);
$Search = true;
}

if ($Search) {
$ExistingUsers = $UserModel->getWhere()->resultArray();
Expand Down Expand Up @@ -604,7 +609,10 @@ public function connect($Method) {
$EmailValid = validateRequired($this->Form->getFormValue('Email'));
}

if ($this->Form->getFormValue('Name') && $EmailValid && (!is_array($ExistingUsers) || count($ExistingUsers) == 0)) {
if ((!$UserSelect || $UserSelect == 'other') &&
$this->Form->getFormValue('Name') && $EmailValid &&
(!is_array($ExistingUsers) || count($ExistingUsers) == 0)) {

// There is no existing user with the suggested name so we can just create the user.
$User = $this->Form->formValues();
$User = $this->UserModel->filterForm($User, true);
Expand All @@ -627,6 +635,7 @@ public function connect($Method) {
'UniqueID' => $this->Form->getFormValue('UniqueID')));

$this->Form->setFormValue('UserID', $UserID);
$this->Form->setFormValue('UserSelect', false);

Gdn::session()->start($UserID, true, (bool)$this->Form->getFormValue('RememberMe', true));
Gdn::userModel()->fireEvent('AfterSignIn');
Expand All @@ -650,8 +659,6 @@ public function connect($Method) {
// The user has made their decision.
$PasswordHash = new Gdn_PasswordHash();

$UserSelect = $this->Form->getFormValue('UserSelect');

if (!$UserSelect || $UserSelect == 'other') {
// The user entered a username.
$ConnectNameEntered = true;
Expand Down
1 change: 1 addition & 0 deletions conf/config-defaults.php
Expand Up @@ -63,6 +63,7 @@
$Configuration['Garden']['Registration']['ConfirmEmail'] = FALSE;
$Configuration['Garden']['Registration']['ConfirmEmailRole'] = 3;
$Configuration['Garden']['Registration']['MinPasswordLength'] = 6;
$Configuration['Garden']['Registration']['NameUnique'] = true;
$Configuration['Garden']['TermsOfService'] = '/home/termsofservice'; // The url to the terms of service.
$Configuration['Garden']['Email']['UseSmtp'] = FALSE;
$Configuration['Garden']['Email']['SmtpHost'] = '';
Expand Down

0 comments on commit e24fcd4

Please sign in to comment.