From: Evan Prodromou Date: Fri, 20 Nov 2009 10:50:43 +0000 (-0800) Subject: Revert "Added 'login' command that gives you a link that can be used to login to... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=224d82793c769c06d1e4f39c19cd5f2e9cf519b0;p=quix0rs-gnu-social.git Revert "Added 'login' command that gives you a link that can be used to login to the website" This reverts commit b9d40f723bce8e01ddcbbb989bd7035b92cd9af8. Conflicts: actions/login.php classes/statusnet.ini db/08to09.sql db/08to09_pg.sql db/statusnet_pg.sql lib/command.php lib/commandinterpreter.php --- diff --git a/actions/login.php b/actions/login.php index cee29fd09e..cd13268134 100644 --- a/actions/login.php +++ b/actions/login.php @@ -79,8 +79,6 @@ class LoginAction extends Action $this->clientError(_('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->checkLogin(); - } else if (isset($args['user_id']) && isset($args['token'])){ - $this->checkLogin($args['user_id'],$args['token']); } else { common_ensure_session(); $this->showForm(); @@ -97,7 +95,7 @@ class LoginAction extends Action * @return void */ - function checkLogin($user_id=null, $token=null) + function checkLogin() { if(isset($token) && isset($user_id)){ //Token based login (from the LoginCommand) @@ -139,6 +137,11 @@ class LoginAction extends Action $user = common_check_user($nickname, $password); } + $nickname = common_canonical_nickname($this->trimmed('nickname')); + $password = $this->arg('password'); + + $user = common_check_user($nickname, $password); + if (!$user) { $this->showForm(_('Incorrect username or password.')); return; diff --git a/classes/Login_token.php b/classes/Login_token.php deleted file mode 100644 index bd6381f903..0000000000 --- a/classes/Login_token.php +++ /dev/null @@ -1,42 +0,0 @@ -. - */ - -if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } - -require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; - -class Login_token extends Memcached_DataObject -{ - ###START_AUTOCODE - /* the code below is auto generated do not remove the above tag */ - - public $__table = 'login_token'; // table name - public $user_id; // int(4) primary_key not_null - public $token; // char(32) not_null - public $created; // datetime() not_null - public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP - - /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Login_token',$k,$v); } - - /* the code above is auto generated do not remove the tag below */ - ###END_AUTOCODE -} diff --git a/db/08to09.sql b/db/08to09.sql index 64640f4ced..8d463fab4c 100644 --- a/db/08to09.sql +++ b/db/08to09.sql @@ -72,13 +72,4 @@ create table location_namespace ( created datetime not null comment 'date the record was created', modified timestamp comment 'date this record was modified' -) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; - -create table login_token ( - user_id integer not null comment 'user owning this token' references user (id), - token char(32) not null comment 'token useable for logging in', - created datetime not null comment 'date this record was created', - modified timestamp comment 'date this record was modified', - - constraint primary key (user_id) -) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; \ No newline at end of file diff --git a/db/08to09_pg.sql b/db/08to09_pg.sql index 7aaf3a7a00..de6a822090 100644 --- a/db/08to09_pg.sql +++ b/db/08to09_pg.sql @@ -39,15 +39,6 @@ create table profile_role ( ); -create table login_token ( - user_id integer not null /* comment 'user owning this token'*/ references "user" (id), - token char(32) not null /* comment 'token useable for logging in'*/, - created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created'*/, - modified timestamp /* comment 'date this record was modified'*/, - - primary key (user_id) -); - DROP index fave_user_id_idx; CREATE index fave_user_id_idx on fave (user_id,modified); @@ -58,5 +49,4 @@ DROP index subscription_subscribed_idx; CREATE index subscription_subscribed_idx ON subscription (subscribed,created); DROP index notice_profile_id_idx; -CREATE index notice_profile_id_idx ON notice (profile_id,created,id); - +CREATE index notice_profile_id_idx ON notice (profile_id,created,id); \ No newline at end of file diff --git a/db/statusnet.sql b/db/statusnet.sql index 18abcdfdb2..f7b3b113b4 100644 --- a/db/statusnet.sql +++ b/db/statusnet.sql @@ -575,13 +575,3 @@ create table location_namespace ( modified timestamp comment 'date this record was modified' ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; - -create table login_token ( - user_id integer not null comment 'user owning this token' references user (id), - token char(32) not null comment 'token useable for logging in', - created datetime not null comment 'date this record was created', - modified timestamp comment 'date this record was modified', - - constraint primary key (user_id) -) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; - diff --git a/db/statusnet_pg.sql b/db/statusnet_pg.sql index 927925753e..27b189e288 100644 --- a/db/statusnet_pg.sql +++ b/db/statusnet_pg.sql @@ -568,14 +568,4 @@ create table profile_role ( primary key (profile_id, role) -); - -create table login_token ( - user_id integer not null /* comment 'user owning this token'*/ references "user" (id), - token char(32) not null /* comment 'token useable for logging in'*/, - created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created'*/, - modified timestamp /* comment 'date this record was modified'*/, - - primary key (user_id) -); - +); \ No newline at end of file diff --git a/lib/command.php b/lib/command.php index 7e98156b66..bcc551c817 100644 --- a/lib/command.php +++ b/lib/command.php @@ -579,32 +579,6 @@ class OnCommand extends Command } } -class LoginCommand extends Command -{ - function execute($channel) - { - $login_token = Login_token::staticGet('user_id',$this->user->id); - if($login_token){ - $login_token->delete(); - } - $login_token = new Login_token(); - $login_token->user_id = $this->user->id; - $login_token->token = common_good_rand(16); - $login_token->created = common_sql_now(); - $result = $login_token->insert(); - if (!$result) { - common_log_db_error($login_token, 'INSERT', __FILE__); - $channel->error($this->user, sprintf(_('Could not create login token for %s'), - $this->user->nickname)); - return; - } - $channel->output($this->user, - sprintf(_('This link is useable only once, and is good for only 2 minutes: %s'), - common_local_url('login', - array('user_id'=>$login_token->user_id, 'token'=>$login_token->token)))); - } -} - class SubscriptionsCommand extends Command { function execute($channel) @@ -692,7 +666,6 @@ class HelpCommand extends Command "reply # - reply to notice with a given id\n". "reply - reply to the last notice from user\n". "join - join group\n". - "login - Get a link to login to the web interface\n". "drop - leave group\n". "stats - get your stats\n". "stop - same as 'off'\n". diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php index 665015afcc..25f2e4b3eb 100644 --- a/lib/commandinterpreter.php +++ b/lib/commandinterpreter.php @@ -41,12 +41,6 @@ class CommandInterpreter return null; } return new HelpCommand($user); - case 'login': - if ($arg) { - return null; - } else { - return new LoginCommand($user); - } case 'subscribers': if ($arg) { return null; diff --git a/lib/router.php b/lib/router.php index b221851267..beb98eb04d 100644 --- a/lib/router.php +++ b/lib/router.php @@ -88,8 +88,6 @@ class Router $m->connect('doc/:title', array('action' => 'doc')); - $m->connect('main/login?user_id=:user_id&token=:token', array('action'=>'login'), array('user_id'=> '[0-9]+', 'token'=>'.+')); - // main stuff is repetitive $main = array('login', 'logout', 'register', 'subscribe',