diff --git a/src/LoginForm/LoginForm.xml b/src/LoginForm/LoginForm.xml
index c2d023b..96c8b01 100644
--- a/src/LoginForm/LoginForm.xml
+++ b/src/LoginForm/LoginForm.xml
@@ -51,6 +51,11 @@
Behavior
Display a progress bar while signing in
+
+ Lower case username
+ Display
+ Automatically converts the username entered to lowercase before authenticating.
+
Show/mask password toggle
Password
@@ -97,6 +102,33 @@
Mobile
Enables/disables auto capitalize functionality on username input field for mobile devices
+
+ Context Entity
+ Before Login
+ The context entity, which will be passed to the before login microflow.
+
+
+ Username Attribute
+ Before Login
+ The username attribute of the context entity
+
+
+
+
+
+ Password Attribute
+ Before Login
+ The password attribute of the context entity
+
+
+
+
+
+ Before login microflow
+ Before Login
+ Microflow fire before trying to log in. Useful for custom SSO solutions.
+
+
diff --git a/src/LoginForm/widget/LoginForm.js b/src/LoginForm/widget/LoginForm.js
index 8a13da7..193f19d 100644
--- a/src/LoginForm/widget/LoginForm.js
+++ b/src/LoginForm/widget/LoginForm.js
@@ -39,12 +39,18 @@
* ======================
*/
_handle: null,
+ _contextObj: null,
+ beforeloginmf: "",
+ userAttr: "",
+ passwordAttr: "",
+ forceUserLowercase: false,
// Extra variables
_userInput : null,
_passInput : null,
_captionShow : null,
_captionHide : null,
+ _currentE: null,
_indicator : null,
_i18nmap : null,
@@ -78,7 +84,9 @@
*/
update: function (obj, callback) {
-
+
+ this._contextObj = obj;
+
// Execute callback.
if (typeof callback !== 'undefined') {
callback();
@@ -186,58 +194,7 @@
// Attach events to newly created nodes.
_setupEvents: function () {
- on(this.submitButton, 'click', lang.hitch(this, function(e) {
-
- var user = null,
- pass = null,
- promise = null;
-
- domStyle.set(this.messageNode, 'display', 'none');
-
- if (attr.get(this._passInput, 'type') === 'text') {
- attr.set(this._passInput, 'type', 'password');
- dom.byId(this.id + '_view').innerHTML = this._captionShow;
- }
-
- logger.debug(this.id + '.submitForm');
-
- user = this._userInput.value;
- pass = this._passInput.value;
-
- if(user && pass) {
- if (typeof this._indicator !== 'undefined' && this._indicator){
- this._indicator.start();
- }
-
- dojo.rawXhrPost({
- url : mx.baseUrl,
- mimetype : 'application/json',
- contentType : 'application/json',
- handleAs : 'json',
- headers : {
- 'csrfToken' : mx.session.getCSRFToken()
- },
- postData : dojoJSON.toJson({
- action : "login",
- params : {
- username : user,
- password : pass,
- locale : ""
- }
- }),
- handle : lang.hitch(this, this._validate)
- });
-
- } else {
- domStyle.set(this.messageNode, 'display', 'block');
- this.messageNode.innerHTML = this.emptytext;
- }
-
- event.stop(e);
-
- return false;
-
- }));
+ on(this.submitButton, 'click', lang.hitch(this, this._onSubmit));
if(this.forgotmf)
{
@@ -316,6 +273,101 @@
this.messageNode.innerHTML = message; // is only reached when xhrstatus !== 200
domStyle.set(this.messageNode, 'display', 'block');
},
+
+ _onSubmit: function(e) {
+ this._currentE = e;
+
+ if(this.beforeloginmf) {
+ this._contextObj.set(this.userAttr, this._userInput.value);
+ this._contextObj.set(this.passwordAttr, this._passInput.value);
+ event.stop(e);
+
+ mx.data.action({
+ params: {
+ applyto: "selection",
+ actionname: this.beforeloginmf,
+ guids: [ this._contextObj.getGuid() ]
+ },
+ store: {
+ caller: this.mxform
+ },
+ callback: lang.hitch(this, function(obj) {
+ if(obj) {
+ this._loginSubmit(this._currentE);
+ } else {
+ this.messageNode.innerHTML = "Failed to authenticate";
+ domStyle.set(this.messageNode, 'display', 'block');
+ }
+ }),
+ error: lang.hitch(this, function(error) {
+ logger.error(this.id + ": An error occurred while executing microflow: " + error.description);
+ })
+ }, this);
+ } else {
+ this._loginSubmit(e);
+ }
+
+ },
+
+ _loginSubmit: function(e) {
+
+ var user = null,
+ pass = null,
+ promise = null;
+
+ domStyle.set(this.messageNode, 'display', 'none');
+
+ if (attr.get(this._passInput, 'type') === 'text') {
+ attr.set(this._passInput, 'type', 'password');
+ dom.byId(this.id + '_view').innerHTML = this._captionShow;
+ }
+
+ logger.debug(this.id + '.submitForm');
+
+ user = this._userInput.value;
+ pass = this._passInput.value;
+
+ //ET 3/31/2016
+ if (this.forceUserLowercase) {
+ user = user.toLowerCase();
+ }
+
+
+ if(user && pass) {
+ if (typeof this._indicator !== 'undefined' && this._indicator){
+ this._indicator.start();
+ }
+
+ dojo.rawXhrPost({
+ url : mx.baseUrl,
+ mimetype : 'application/json',
+ contentType : 'application/json',
+ handleAs : 'json',
+ headers : {
+ 'csrfToken' : mx.session.getCSRFToken()
+ },
+ postData : dojoJSON.toJson({
+ action : "login",
+ params : {
+ username : user,
+ password : pass,
+ locale : ""
+ }
+ }),
+ handle : lang.hitch(this, this._validate)
+ });
+
+ } else {
+ domStyle.set(this.messageNode, 'display', 'block');
+ this.messageNode.innerHTML = this.emptytext;
+ }
+
+ event.stop(e);
+
+ return false;
+
+ },
+
_getI18NMap : function() {
logger.debug(this.id + '.injectI18NMap');
diff --git a/src/package.xml b/src/package.xml
index 914c219..5f81f78 100644
--- a/src/package.xml
+++ b/src/package.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/test/LoginForm Test.mpr b/test/LoginForm Test.mpr
index ea5a6ba..2b840b2 100644
Binary files a/test/LoginForm Test.mpr and b/test/LoginForm Test.mpr differ
diff --git a/test/LoginForm Test.mpr.bak b/test/LoginForm Test.mpr.bak
new file mode 100644
index 0000000..b30b649
Binary files /dev/null and b/test/LoginForm Test.mpr.bak differ
diff --git a/test/widgets/LoginForm.mpk b/test/widgets/LoginForm.mpk
index a3aaa40..89e0a71 100644
Binary files a/test/widgets/LoginForm.mpk and b/test/widgets/LoginForm.mpk differ