- Notifications
You must be signed in to change notification settings - Fork2
A CUBA framework component that lets an authenticated user change his/her details. It also offer a REST API to be consumed by third party applications, or by Polymer clients.
License
cubait/cuba-component-user-profile
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This add-on gives the following features once added to a CUBA project:
- Provides a
UserProfileService
with methods for getting and updating the details of the current logged in user (what I call theuser profile) - Exposes a new REST API endpoint (Richardson Maturity Model - Level 2 compliant), called
/rest/nxsecup/v1/userProfile
supporting GET (getProfile
)and PUT (updateProfile
) requests, and a/rest/nxsecup/v1/userProfile/password
endpoint supporting POSTrequests for updating the user's password - Adds a
userProfile
screen, and corresponding menu item after the Settings one in the Help main menu - Optionally hides theChange password button from the
Settings
screen (because that button is replicated in theuserProfile
screen)
UPDATE FOR CUBA >= 7.1: This add-on adds a dependency to theREST API add-ononce added to your project.
NOTE: This add-on's repository is officially linked to the main CUBA repository.
You can jump straight to step 2. for instructions on how to add it to your project, oroptionallyyou can choose to add my repository to your project's repositories.
- [OPTIONAL] Add the following maven repository
https://dl.bintray.com/pfurini/cuba-components
to the build.gradle of your CUBA application:
buildscript { //... repositories { // ... maven { url "https://dl.bintray.com/pfurini/cuba-components" } } // ...}
- Select a version of the add-on which is compatible with the platform version used in your project:
Platform Version | Add-on Version | Coordinates |
---|---|---|
6.6.* | 0.2.2 | it.nexbit.cuba.security.userprofile:nxsecup-global:0.2.2 |
6.7.* | N/A | not compatible |
6.8.* | 0.3.0 | it.nexbit.cuba.security.userprofile:nxsecup-global:0.3.0 |
6.9.* | 1.0.0 | it.nexbit.cuba.security.userprofile:nxsecup-global:1.0.0 |
6.10.* | 1.1.0 | it.nexbit.cuba.security.userprofile:nxsecup-global:1.1.0 |
7.0.* | 2.0.0 | it.nexbit.cuba.security.userprofile:nxsecup-global:2.0.0 |
7.1.* | 3.0.0 | it.nexbit.cuba.security.userprofile:nxsecup-global:3.0.0 |
The latest stable version is:3.0.0
- Install the correct add-on version in your project usingCUBA Studio, or manually by editing your
build.gradle
file.
PLEASE NOTE that new features are developed only in the latest releases, while only critical bug fixesare back-ported to older ones. Please update your CUBA version as soon as possible, if you are in need ofsome features available only in a recent release (see theCHANGELOG for reference).
N/A - This component does not need any data
NONE
The component behavior can be altered by means of configuration properties, and custom views.
The following properties can be set in*.properties
files (typically in yourweb-app.properties
file).For programmatic access, use to theUserProfileConfig
interface.
Property | Default Value | Description |
---|---|---|
ext.security.hideChangePasswordInSettings | false | Set totrue to hide theChange password button in theSettings screen |
ext.security.defaultViewForUserProfile | user.profile | The view used by theUserProfileService#getProfile() method to select which properties to include in the returnedUser entity |
ext.security.defaultViewForUserProfileUpdate | user.profileUpdate | The view used by theUserProfileService#updateProfile(User) method to determine which properties will be updated in theUser entity stored in the currentUserSession |
The following views are the ones used by default in thedefaultView*
application properties.Extend or replace them if the default properties are not suitable for your app.
<viewclass="com.haulmont.cuba.security.entity.User"extends="_minimal"name="user.profile"> <propertyname="loginLowerCase"/> <propertyname="firstName"/> <propertyname="lastName"/> <propertyname="middleName"/> <propertyname="position"/> <propertyname="email"/> <propertyname="language"/> <propertyname="timeZone"/> <propertyname="timeZoneAuto"/> <propertyname="changePasswordAtNextLogon"/> <propertyfetch="JOIN"name="group"view="_minimal"/> <propertyfetch="JOIN"name="userRoles"> <propertyfetch="JOIN"name="role"view="_minimal"/> </property></view><viewclass="com.haulmont.cuba.security.entity.User"name="user.profileUpdate"> <propertyname="firstName"/> <propertyname="lastName"/> <propertyname="middleName"/> <propertyname="position"/> <propertyname="email"/> <propertyname="language"/> <propertyname="timeZone"/> <propertyname="timeZoneAuto"/> <propertyname="name"/></view>
If you usePostman (and if you don't, you should), then click the following button to importa collection with all the requests
And here is the public documentation URL:REST API Docs
Every request makes use of the following variables:
Variable name | Description |
---|---|
{{baseurl}} | The base URL for the requests, for examplehttp://localhost:8080/app/rest |
{{bearer}} | An auth token obtained by calling the/rest/v2/oauth/token endpoint |
HINT: you can paste the following script in theTests
tab of the/rest/v2/oauth/token
requestto automatically set thebearer
variable after a successful auth
var jsonData = JSON.parse(responseBody)pm.environment.set("bearer", jsonData.access_token);
For your convenience, aGet Access Token request is already included in the Postman collection. Only makesure to update thesec-user-profile TEST environment to reflect your app URL (by default thebaseurl
variable is set tohttp://localhost:8080/app/rest
)
The following are the methods exposed by theextsec_UserProfileService
, through the standardREST API endpoint (/rest/v2/services
).
<?xml version="1.0" encoding="UTF-8"?><servicesxmlns="http://schemas.haulmont.com/cuba/rest-services-v2.xsd"> <servicename="extsec_UserProfileService"> <methodname="getProfile"/> <methodname="updateProfile"> <paramname="user"/> </method> </service></services>
The component exposes an alternative REST endpoint (/rest/nxsecup/v1
) that aligns best toLevel 2 of theRichardson Maturity Model. It is more resource oriented than the service basedapproach of the official REST API, and it makes use of HTTP verbs correctly.
Here is a brief list of the supported endpoints (please use thePostman collection above to play withthe actual requests in your project):
Endpoint | Verb | Description |
---|---|---|
{{baseurl}}/nxsecup/v1/userProfile | GET | Get the JSON representation of theUser entity in the currentUserSession (filtered by theext.security.defaultViewForUserProfile view) |
{{baseurl}}/nxsecup/v1/userProfile | PUT | Update theUser entity associated with the currentUserSession (actual fields updated are filtered by theext.security.defaultViewForUserProfileUpdate view) |
{{baseurl}}/nxsecup/v1/userProfile/password | GET | Update the password for the current user, with aGET operation (append?password=newPasswordToSet ) |
{{baseurl}}/nxsecup/v1/userProfile/password | POST | Update the password for the current user, with aPOST operation (use the JSON{"password": "newPasswordToSet"} ) |
Theuser-edit-profile
screen can be extended in the usual CUBA way, so that you can add/remove/altertheUser
entity fields exposed to the user.
About
A CUBA framework component that lets an authenticated user change his/her details. It also offer a REST API to be consumed by third party applications, or by Polymer clients.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.