<?php
-
/**
- * @file src/Module/Login.php
+ * @copyright Copyright (C) 2010-2022, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * 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 <https://www.gnu.org/licenses/>.
+ *
*/
namespace Friendica\Module\Security;
use Friendica\BaseModule;
-use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\Register;
-use Friendica\Util\Strings;
/**
* Login module
- *
- * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Login extends BaseModule
{
- public static function content(array $parameters = [])
+ protected function content(array $request = []): string
{
+ $return_path = $_REQUEST['return_path'] ?? '' ;
+
if (local_user()) {
- DI::baseUrl()->redirect();
+ DI::baseUrl()->redirect($return_path);
+ } elseif (!empty($return_path)) {
+ Session::set('return_path', $return_path);
}
return self::form(Session::get('return_path'), intval(DI::config()->get('config', 'register_policy')) !== \Friendica\Module\Register::CLOSED);
}
- public static function post(array $parameters = [])
+ protected function post(array $request = [])
{
$return_path = Session::get('return_path');
Session::clear();
if (is_array($attr) && count($attr)) {
foreach ($attr as $k => $v) {
if ($k === 'namePerson/friendly') {
- $nick = Strings::escapeTags(trim($v));
+ $nick = trim($v);
}
if ($k === 'namePerson/first') {
- $first = Strings::escapeTags(trim($v));
+ $first = trim($v);
}
if ($k === 'namePerson') {
- $args['username'] = Strings::escapeTags(trim($v));
+ $args['username'] = trim($v);
}
if ($k === 'contact/email') {
- $args['email'] = Strings::escapeTags(trim($v));
+ $args['email'] = trim($v);
}
if ($k === 'media/image/aspect11') {
$photosq = bin2hex(trim($v));
$args['photo'] = $photo;
}
- $args['openid_url'] = Strings::escapeTags(trim(Session::get('openid_identity')));
+ $args['openid_url'] = trim(Session::get('openid_identity'));
return 'register?' . http_build_query($args);
}