request = \Config\Services::request(); } public function index(): string { return ''; } public function startBkoToken() { $data = $this->request->getPost(); if ( $data['username'] == 'demo@demo.com' && $data['pass']=== 'demo1' ){ $final_out = $data; $key = getenv('JWT_SECRET'); $iat = time(); // current timestamp value $exp = $iat + 3600; $payload = array( "iss" => "Issuer of the JWT", "aud" => "Audience that the JWT", "sub" => "Backoffice VerifiedT", "iat" => $iat, //Time the JWT issued at "exp" => $exp, // Expiration time of token "user_detail" =>$final_out, ); $token = JWT::encode($payload, $key, 'HS256'); $response = [ 'message' => 'Login was successful', 'call_return' => '100', 'name' => 'didiFy Admin', 'username' => $data['username'], 'token' => $token ]; return $this->respond($response, 200); } else{ $response = [ 'message' => 'Login failed', 'call_return' => '100', 'token' => '' ]; return $this->fail($response , 409); } } }