How to get user related data with Generic Interface in OTRS 6? - perl

I wonder how to get User Data with Generic Interface. It seems that there is no Controller to get User Data...
these are the only controllers:
So how can I add user methods to my webservices?
I tried adding a User section in my webservice.yml and reimported it:
User:
Description: Search for User Data
MappingInbound: {}
MappingOutbound: {}
Type: Kernel::System::User
but that didn't work. OTRS says that there is no Controller for Kernel::System::User. I also tried only to set Type to User. Same error.
Since the generic interface replaces the deprecated RPC.pl API, it should have at least the same set of methods.
Otherwise this would'nt be an improvement of the API right?

You can create controller by youself, it's not that hard.
Take a look at existing services in Kernel/GenericInterface/Operation/*
Register new operation with XML, look for examples here: Kernel/Config/Files/XML/GenericInterface.xml
Don't forget to call:
/opt/otrs/bin/otrs.SetPermissions.pl (as root)
/opt/otrs/bin/otrs.Console.pl Maint::Config::Rebuild
after creation of new files

Related

Using mashape api in sapui5

I'm fairly new to sapui5 and I'm trying to use the Hearthstone API in order to show a list of cards.
I've registered in the page and I've obtained the X-Mashape-Key which I'm using to try to connect to the API.
For this, I've created a destination with the following information:
Besides this, I've created a view and its corresponding controller with the onInit function, with the following code:
Being the sUrl: /hsApi/cards and oHeaders:
var oHeaders = {
"X-Mashape-Key": "key"
};
The result that I obtain is the following one:
Request is failing stating that I'm not authorized to request the information, even though that doing the same request in PostMan I'm obtaining the information.
Most likely, this is caused by something really obvious but I'm not able to see it.
Could you try adding the following property to your destination? I am not sure what this property does exactly, but maybe you need it to allow this destination to be used in your WebIDE. Also try changing your "True" and "TRUE" to lowercase "true".
But I think you don't need any "Additional property" at all. Can't hurt to try it without them aswell.
Please keep in mind that you need to restart your WebIDE everytime you change something in your destinations as those are loaded statically every time the WebIDE loaded.

How to send email when user is created from BCC ATG?

On creation of new external user from ATG BCC, I need to include some logic like encrypting password and sending email to user. Achieved this functionality by extending GSAPropertyDescriptor class and overriding its getPropertyValue(RepositoryItemImpl pItem, Object pValue) method.
Problem is, this method is getting called only when we click on create button from "General" tab present in users section, but not on click of same create button from other tabs like "Commerce", "Orgs & Roles", "User Segments" and "Advanced".
Please suggest!!
It is not a good idea to override getPropertyValue of an item for this implementation. The right way to do this is to work with the formhandler that is responsible for saving the user. It is a bit tricky to find this formhandler. It will be in the atg/web/viewmapping/ViewMappingRepository/ of the BCC instance. In this repository there will be lots of formhandlers configured for different purposes. You have to pick the one relevant for the user edit. Here is an example of what you might find there:
With this, you go to appropriate Formhanlder, like /atg/web/assetmanager/editor/profile/UserFormHandler mentioned here. And override that component in your module with your own implementation. Once that is done, you'll have the control of the action. You can do your work and pass on the control to super class (the original implementation).
Regards,
Jags

Sailsjs overwrite post action in controller

Short question, tried finding an IRC for sails for such a quick one but got lost so here goes. I have a controller with a route of '/userposts'. I know sails offers some default REST-like functionality without backend code needed but what if I want to overwrite the default POST action what would I do?
I'm forced to write a POST route such as post /userposts/create or I can overwrite the default action and post straight to /userposts which will identify my overwriting and execute it.
I hope I'm making sense. I basically want to create a custom POST route and be able to
socket.post('/userposts', {title: "Foo", content: "Bar"}, function(response){});
I tried with create but it doesn't get executed on a post to /userposts
Sails.js provides blueprints out of the box.
These blueprints provide you with the following CRUD routes that are enabled by default
/:controller/find/:id?
/:controller/create
/:controller/update/:id
/:controller/destroy/:id
To modify the default functionality for your controllers, look at the settings in config/controllers.js
Your routes are defined within config/routes.js, in your case you have a model UserPosts and a corresponding controller named UserPostsController.
In your UserPosts controller, create a function createPost and specify the route(s) to this method
'POST /userposts/create': 'UserPostsController.createPost'
which is shorthand for
'POST /userposts/create': {
controller: 'userposts',
action: 'createPost'
}
you can also override the /:controller route
'POST /userposts': 'UserPostsController.createPost'
These routes will map any POST requests made to the createPost function.
For more information, be sure to check out the Sails.js documentation

Replacing MVC's built in User objects with Facebook Connect

I have an ASP.NET MVC 3 project where I have NO local user management. I have intergratred Facebook Connect successfully. While this works, it makes my Controllers and Views messy and verbose.
I'd like to replace the default objects such as the User object exposed by Controllers and Views to return my FacebookUser object instead.
Anyone have a better solution than having my Controllers digging around in FacebookWebContex.? It just feels dirty.
Not quite sure which facebook library you are using. But if you impliment IPrincipal and IIdentity in your FacebookUser object, you will be able to set HttpContext.Current.User to that FacebookUser which will allow you to pull that FacebookUser instance from the User property in the controller.

Zend Controller Plugins vs Subclassing Action Controller

I've got a pretty standard ACL system in my application. There's a Login controller and a bunch of other controllers redirecting back to Login if user is not authorized. I use a Controller Plugin for checking the ID and redirecting and I obviously don't want Login controller and Error controller to perform such a redirect.
Now I've read several times that using Controller Plugins is a better practice than subclassing the Action Controller. Yet what I see is it's much easier to extend all my controllers from this abstract base controller class which performs the necessary checking in its init method, except for the Login controller which extends Zend_Controller_Action directly.
So the question is, is there a way to attach the plugin to the controllers selectively? Of course I can always make an array out of certain controllers, send it to a plugin through a setter method and do something like:
$controller = $request->getParam('controller');
if (count($this->exceptions))
if (in_array($controller, $this->exceptions)) return;
//...check ID, perform redirect, etc...
Yet something tells me it's not the best way doing it.
And advices?
EDIT 1: #Billy ONeal
Thank you for your reply, but I don't quite catch. I can do
public function init()
{
$this->getRequest()->setParam('dropProtection', true);
}
(or run some method that sets some private variable of the plugin) in my login controller, and then say if 'dropProtection' is not true then check the user ID. But the actual dispatch process looks like this:
Plugin::dispatchLoopStartup
Plugin::preDispatch
Controller::init
Plugin::postDispatch
Plugin::preDispatch
Plugin::postDispatch
Plugin::dispatchLoopShutdown
So I cannot check this 'dropProtection' param earlier than in Plugin::postDispatch and that's a bit late. (by the way, why the preDispatch and postDispatch are being called twice?)
If you want to do it earlier, I think you can use the first method (passing an array of exceptions to the plugin) and test the module name or the controller name in routeShutdown.
Personnaly I use an action helper to check the auth in all my actions. It's more flexible and give me more control. It's only one line for each private action.
And DON'T SUBCLASS your action controller. I did it on one of my project and now my base class is a piece of shit. Use action helper instead.
is there a way to attach the plugin to the controllers selectively?
Of course. Just don't register the plugin if the request doesn't contain the parameters you're looking for. Alternately, assume all pages are protected, and have those pages which should not be protected call some method on your plugin during the init stage.
If you want to protect just a single controller, you could reverse that -- have the plugin only take action if there's some method called during the init stage.
Finally, you could make the entire logged-in section of the page it's own module, which would allow you to have the plugin check for that module before checking credentials and redirecting.