[
https://issues.apache.org/jira/browse/OFBIZ-10515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16625046#comment-16625046 ]
Taher Alkhateeb commented on OFBIZ-10515:
-----------------------------------------
The way I recommend refactoring the userImpersonate is by dividing work into specialized areas. This function has too many if this then that blocks followed by a big try / catch block. So here are some ideas that might be helpful:
* Try to put all the data preparation logic in one place / function
* Try to put all the validation logic in one function, perhaps it would return a boolean or a string
* Try to put the failing of the services from validation errors (returning different error messages) in one place.
* Try to construct the returned data in one place.
* Minimize the scope of try / catch to the essentials / mandatory things.
So in essence, you would ideally have one place for preparing data, one place for validation, one place for failing, and one place for the logic of building the service returned data.
> Impersonation of userLogin feature
> ----------------------------------
>
> Key: OFBIZ-10515
> URL:
https://issues.apache.org/jira/browse/OFBIZ-10515> Project: OFBiz
> Issue Type: Improvement
> Affects Versions: Trunk
> Reporter: Gil Portenseigne
> Assignee: Gil Portenseigne
> Priority: Minor
> Fix For: Upcoming Branch
>
> Attachments: ImpersonationWidget.png, OFBIZ-10515.patch, OFBIZ-10515.patch, OFBIZ-10515.patch, OFBIZ-10515.patch, OFBIZ-10515.patch, impersonate-ico.png, impersonateButton.png
>
>
> This JIRA introduce a new feature that allow the impersonation of a login by an authorized user.
> This is implemeted with :·
> * A new service ‘userImpersonate’ that will check security, store impersonation in UserLoginHistory, and return the new session
> * Events ‘userImpersonate’ and ‘userDepersonate’ that will allow impersonation/depersonation action persisting current user session
> * A new modal widget in the common-theme that inform the user about ‘impersonation in process’ and offering a way to depersonate.
> * A new field in UserLoginHistory to store impersonation originator
> * A button in party viewprofile page to illustrate the feature
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)