Files
WrenchBoradWeb/www-api/app/Controllers/WrenchAuth.php
T
CHIEFSOFT\ameye 8394788967 New sessio
2024-07-07 18:54:05 -04:00

50 lines
1.7 KiB
PHP

<?php
namespace App\Controllers;
use CodeIgniter\API\ResponseTrait;
class WrenchAuth extends BaseController
{
use ResponseTrait;
public function userLogin(){
// $in = $this->request->getPostGet();
$raw_json = file_get_contents('php://input');
$in = json_decode($raw_json, true);
$in["action"] = WRENCHBOARD_ACCOUNT_LOGIN;
if (!isset($in["login_mode"])){
$in["login_mode"] = MOBILE_LOGIN;
}
$out=[];
// $out = $this->getCache($endpoint); // try find in cache
$ret = $this->wrenchboard->wrenchboard_api($in, $out);
$out['internal_return'] = $ret;
log_message('critical', "***** ***** WrenchAuth::userLogin Ret = ".$ret );
if ( $out['internal_return'] == 100 ){
$endpoint = "USER_SESSION-". str_pad($out["member_id"], 12, "0", STR_PAD_LEFT) ."-";
log_message('critical', "***** ***** WrenchAuth::userLogin USER_SESSION = ".$endpoint );
$this->saveCache($endpoint,$out,15000);
}else
{
// make safe for redis
$outF["username"] = str_replace("@", "_", $in["username"]);
$outF["username"] = str_replace(".", "_", $outF["username"]);
$outF["loc"] = $in["loc"];
$endpoint = "LOGIN_FAILED-".$outF["username"]."-";
log_message('critical', "***** ***** WrenchAuth::userLogin USER_SESSION = ".$endpoint );
$this->saveCache($endpoint,$outF,15000);
}
// }
return $this->respond( $this->summaryReturnData($in,$out), 200);
// return $this->summaryReturnData($in,$out); //json_encode( $final_out );
}
}
// WrenchAuth::userLogin