Skip to content

Commit

Permalink
fixed some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksanderKoko committed Nov 8, 2016
1 parent aa9a6b4 commit 77ab9f4
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plugins/restapi2/call.php
Expand Up @@ -15,7 +15,7 @@
(! isset( $GLOBALS['DEBUG'] ) || $GLOBALS['DEBUG'] == 0)
&& function_exists( 'xdebug_disable' )
) {
xdebug_disable();
//xdebug_disable();
}

// Check that the plugin has been initiatlised
Expand Down
1 change: 1 addition & 0 deletions plugins/restapi2/lib/Admin.php
Expand Up @@ -39,6 +39,7 @@ public function login( $password, $username )

if($data['result']){
$this->admin->setLoginToken($data['admin']->id);
return $this->admin->getLoginToken($data['admin']->id);
}
}

Expand Down
17 changes: 14 additions & 3 deletions plugins/restapi2/lib/Handler/LoginHandler.php
@@ -1,6 +1,7 @@
<?php

namespace Rapi\Handler;
use phpList\helper\Logger;

/**
* Class LoginHandler
Expand All @@ -13,14 +14,24 @@ class LoginHandler
* LoginHandler constructor.
* @param \Rapi\Admin $admin
*/
public function __construct( \Rapi\Admin $admin)
public function __construct( \Rapi\Admin $admin, Logger $logger)
{
$this->admin = $admin;
$logger->debug('LoginHandler was called');
}

public function login($username, $password){
$response = $this->admin->login($username, $password);
return ["message" => "Success"];
$data = $this->admin->login($username, $password);
if($data){
return [
"message" => "Success",
"token" => $data
];
}else{
return [
"message" => "Failure"
];
}
}

}
12 changes: 11 additions & 1 deletion plugins/restapi2/phplist4-bootstrap.php
Expand Up @@ -12,4 +12,14 @@
$pl4Config->setRunningConfig( 'TABLE_PREFIX', $GLOBALS['table_prefix'] );
$pl4Config->setRunningConfig( 'USERTABLE_PREFIX', $GLOBALS['usertable_prefix'] );
// FIXME: Set this hashing algo from phpList3's config instead
$pl4Config->setRunningConfig( 'ENCRYPTION_ALGO', 'md5' );
// Fixed: on PHPList 3 we were using constants with define().
$pl4Config->setRunningConfig( 'ENCRYPTION_ALGO', ENCRYPTION_ALGO );

// Set the folder where the log file should live
$pl4Config->setRunningConfig( 'LOG_FOLDER', '/tmp/');
$pl4Config->setRunningConfig( 'LOG_FILENAME', 'phplist-fork.log');

/**
* file | database
*/
$pl4Config->setRunningConfig( 'LOG_WRITER', 'file');
6 changes: 5 additions & 1 deletion plugins/restapi2/services.yml
Expand Up @@ -33,7 +33,7 @@ services:
arguments: [@ListEntity, @ListManager, @SubscriberEntity]
LoginHandler:
class: Rapi\Handler\LoginHandler
arguments: [@Admin]
arguments: [@Admin, @Logger]

# It seems order matters; hence Call{} definition goes last, not alphabetically
Call:
Expand All @@ -44,8 +44,12 @@ services:
AdminService:
class: phpList\Admin
arguments: [@AdminModel, @Pass]
LoggerWriterAbstractFactory:
class: phpList\helper\Logger\LoggerWriterAbstractFactory
arguments: [@Config]
Logger:
class: phpList\helper\Logger
arguments: [@LoggerWriterAbstractFactory]
Util:
class: phpList\helper\Util
arguments: [@Config, @Logger]
Expand Down

0 comments on commit 77ab9f4

Please sign in to comment.