OAuth app names should be unique.
This commit is contained in:
parent
8a0a891960
commit
dc183f23cf
|
@ -179,6 +179,9 @@ class EditApplicationAction extends OwnerDesignAction
|
||||||
} elseif (mb_strlen($name) > 255) {
|
} elseif (mb_strlen($name) > 255) {
|
||||||
$this->showForm(_('Name is too long (max 255 chars).'));
|
$this->showForm(_('Name is too long (max 255 chars).'));
|
||||||
return;
|
return;
|
||||||
|
} else if ($this->nameExists($name)) {
|
||||||
|
$this->showForm(_('Name already in use. Try another one.'));
|
||||||
|
return;
|
||||||
} elseif (empty($description)) {
|
} elseif (empty($description)) {
|
||||||
$this->showForm(_('Description is required.'));
|
$this->showForm(_('Description is required.'));
|
||||||
return;
|
return;
|
||||||
|
@ -260,5 +263,26 @@ class EditApplicationAction extends OwnerDesignAction
|
||||||
common_redirect(common_local_url('oauthappssettings'), 303);
|
common_redirect(common_local_url('oauthappssettings'), 303);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the app name already exist?
|
||||||
|
*
|
||||||
|
* Checks the DB to see someone has already registered and app
|
||||||
|
* with the same name.
|
||||||
|
*
|
||||||
|
* @param string $name app name to check
|
||||||
|
*
|
||||||
|
* @return boolean true if the name already exists
|
||||||
|
*/
|
||||||
|
|
||||||
|
function nameExists($name)
|
||||||
|
{
|
||||||
|
$newapp = Oauth_application::staticGet('name', $name);
|
||||||
|
if (!$newapp) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return $newapp->id != $this->app->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,6 +158,9 @@ class NewApplicationAction extends OwnerDesignAction
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
$this->showForm(_('Name is required.'));
|
$this->showForm(_('Name is required.'));
|
||||||
return;
|
return;
|
||||||
|
} else if ($this->nameExists($name)) {
|
||||||
|
$this->showForm(_('Name already in use. Try another one.'));
|
||||||
|
return;
|
||||||
} elseif (mb_strlen($name) > 255) {
|
} elseif (mb_strlen($name) > 255) {
|
||||||
$this->showForm(_('Name is too long (max 255 chars).'));
|
$this->showForm(_('Name is too long (max 255 chars).'));
|
||||||
return;
|
return;
|
||||||
|
@ -273,5 +276,22 @@ class NewApplicationAction extends OwnerDesignAction
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the app name already exist?
|
||||||
|
*
|
||||||
|
* Checks the DB to see someone has already registered and app
|
||||||
|
* with the same name.
|
||||||
|
*
|
||||||
|
* @param string $name app name to check
|
||||||
|
*
|
||||||
|
* @return boolean true if the name already exists
|
||||||
|
*/
|
||||||
|
|
||||||
|
function nameExists($name)
|
||||||
|
{
|
||||||
|
$app = Oauth_application::staticGet('name', $name);
|
||||||
|
return ($app !== false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -353,7 +353,7 @@ notice_id = K
|
||||||
id = 129
|
id = 129
|
||||||
owner = 129
|
owner = 129
|
||||||
consumer_key = 130
|
consumer_key = 130
|
||||||
name = 130
|
name = 2
|
||||||
description = 2
|
description = 2
|
||||||
icon = 130
|
icon = 130
|
||||||
source_url = 2
|
source_url = 2
|
||||||
|
@ -367,6 +367,7 @@ modified = 384
|
||||||
|
|
||||||
[oauth_application__keys]
|
[oauth_application__keys]
|
||||||
id = N
|
id = N
|
||||||
|
name = U
|
||||||
|
|
||||||
[oauth_application_user]
|
[oauth_application_user]
|
||||||
profile_id = 129
|
profile_id = 129
|
||||||
|
|
|
@ -214,7 +214,7 @@ create table oauth_application (
|
||||||
id integer auto_increment primary key comment 'unique identifier',
|
id integer auto_increment primary key comment 'unique identifier',
|
||||||
owner integer not null comment 'owner of the application' references profile (id),
|
owner integer not null comment 'owner of the application' references profile (id),
|
||||||
consumer_key varchar(255) not null comment 'application consumer key' references consumer (consumer_key),
|
consumer_key varchar(255) not null comment 'application consumer key' references consumer (consumer_key),
|
||||||
name varchar(255) not null comment 'name of the application',
|
name varchar(255) unique key comment 'name of the application',
|
||||||
description varchar(255) comment 'description of the application',
|
description varchar(255) comment 'description of the application',
|
||||||
icon varchar(255) not null comment 'application icon',
|
icon varchar(255) not null comment 'application icon',
|
||||||
source_url varchar(255) comment 'application homepage - used for source link',
|
source_url varchar(255) comment 'application homepage - used for source link',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user