2008-06-17 22:35:01 +09:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Laconica - a distributed open-source microblogging tool
|
|
|
|
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!defined('LACONICA')) { exit(1); }
|
|
|
|
|
2008-06-17 23:51:40 +09:00
|
|
|
require_once(INSTALLDIR.'/lib/openid.php');
|
|
|
|
|
2008-06-17 22:35:01 +09:00
|
|
|
class OpenidloginAction extends Action {
|
2008-06-17 23:49:42 +09:00
|
|
|
|
2008-06-17 22:35:01 +09:00
|
|
|
function handle($args) {
|
|
|
|
parent::handle($args);
|
|
|
|
if (common_logged_in()) {
|
|
|
|
common_user_error(_t('Already logged in.'));
|
|
|
|
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
2008-06-19 22:47:10 +09:00
|
|
|
$openid_url = $this->trimmed('openid_url');
|
|
|
|
$result = oid_authenticate($openid_url,
|
2008-06-19 00:05:57 +09:00
|
|
|
'finishopenidlogin');
|
2008-06-18 22:32:51 +09:00
|
|
|
if (is_string($result)) { # error message
|
2008-06-19 22:47:10 +09:00
|
|
|
$this->show_form($result, $openid_url);
|
2008-06-18 22:32:51 +09:00
|
|
|
}
|
2008-06-17 22:35:01 +09:00
|
|
|
} else {
|
2008-06-19 22:47:10 +09:00
|
|
|
$openid_url = oid_get_last();
|
|
|
|
$this->show_form(NULL, $openid_url);
|
2008-06-17 22:35:01 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-02 02:24:29 +09:00
|
|
|
function get_instructions() {
|
|
|
|
return _t('Login with an [OpenID](%%doc.openid%%) account.');
|
|
|
|
}
|
|
|
|
|
2008-06-19 04:02:02 +09:00
|
|
|
function show_top($error=NULL) {
|
2008-06-17 22:35:01 +09:00
|
|
|
if ($error) {
|
|
|
|
common_element('div', array('class' => 'error'), $error);
|
|
|
|
} else {
|
2008-07-02 02:24:29 +09:00
|
|
|
$instr = $this->get_instructions();
|
|
|
|
$output = common_markup_to_html($instr);
|
|
|
|
common_element_start('div', 'instructions');
|
|
|
|
common_raw($output);
|
|
|
|
common_element_end('div');
|
2008-06-17 22:35:01 +09:00
|
|
|
}
|
2008-06-19 04:02:02 +09:00
|
|
|
}
|
2008-07-02 02:24:29 +09:00
|
|
|
|
2008-06-19 22:47:10 +09:00
|
|
|
function show_form($error=NULL, $openid_url) {
|
2008-06-19 04:02:02 +09:00
|
|
|
common_show_header(_t('OpenID Login'), NULL, $error, array($this, 'show_top'));
|
2008-06-19 00:05:57 +09:00
|
|
|
$formaction = common_local_url('openidlogin');
|
2008-07-02 22:15:07 +09:00
|
|
|
common_element_start('form', array('method' => 'post',
|
2008-06-17 22:35:01 +09:00
|
|
|
'id' => 'openidlogin',
|
2008-06-19 00:05:57 +09:00
|
|
|
'action' => $formaction));
|
2008-06-19 22:47:10 +09:00
|
|
|
common_input('openid_url', _t('OpenID URL'),
|
|
|
|
$openid_url,
|
|
|
|
_t('Your OpenID URL'));
|
2008-06-17 22:35:01 +09:00
|
|
|
common_submit('submit', _t('Login'));
|
|
|
|
common_element_end('form');
|
|
|
|
common_show_footer();
|
|
|
|
}
|
|
|
|
}
|