on 09-13-2013 8:54 AM
Hi,
I am doing sample gateway application using sapui5 . In that I am passing Username and Password dynamically using Login form.
Previously I am using the below code to set the model.
var oModel = new sap.ui.model.odata.ODataModel(
"http://xxxx:8000/sap/opu/odata/sap/ZPROJ_APPRAISAL_FORM_SRV", true, myusername, mypassword);
In that I am passing username and password dynamically.But I am not able to get the error when I enter wrong Inputs.Next I changed my code like below to catch the error message when I enter wrong Input.
login : function(oEvent) {
}
Here, when I enter valid inputs it goes to server and fetch the data. But when I enter wrong inputs again it is displaying Gateway service Popup with username and Password on the login form. When i click on cancel button of that Popup I am getting the error code which is in error function.
Please find the below Images
Getting Login Screen like this when i enter wrong inputs to the service.
After click on Cancel Button I am getting the Error code like below
Now I want to prevent that POPUP which is coming before error message.
Please help me to solve this issue.
Thanks&Regards
Sridevi
To avoid User and Passowrd Autentication, you need to go SICF tcode and find the service there. In it, put user and Password that will be used. Only that.
I Used it always for SAPUI5 app and WebDynpro App.
Att.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sridevi,
I would do it this way :
var sUrl = "http://xxxx:8000/sap/opu/odata/sap/ZPROJ_APPRAISAL_FORM_SRV";
var oModel = new sap.ui.model.odata.ODataModel(sUrl, true, username, password);
sap.ui.core.BusyIndicator.show(0);// shows a busy indicator while loading the data
oModel.read(
"/", // the path : would put "/" or "" if it doesn't work
null, // context : null by default
[], // urlParameters : empty array as we don't need any here
true, // asynchronous request : true
function(oData, response) { // onSuccess function called when everything is ok
// handle your data here and don't forget the hide the busyIndicator
sap.ui.core.BusyIndicator.hide();
},
function(oError) { // onError function called when there was an error
// Here you can handle the error you got, for example, you can show a dialog with the error msg
jQuery.sap.require("sap.ui.commons.MessageBox");
sap.ui.commons.MessageBox.show(
oError.message,
sap.ui.commons.MessageBox.Icon.ERROR,
"Name of your App"
);
// Finally hide the busyIndicator
sap.ui.core.BusyIndicator.hide();
}
);
For more infos about the sap.ui.model.odata.ODataModel constructor and the read() function you can check this link : OpenUI5 SDK - Demo Kit.
Hope this helps!
Regards,
Mehdi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sridevi
sending the user/password this way is unsecure , as it passes in the url. it's rather a testing feature.
If you are working from the browser , then you can leave user/password out, the browser will get 401 status code and will automatically open the browser authentication dialog box.
then your user can enter his credentials and be authenticated.
From app code you don't need to do anything special for this to work.
BTW, this kind of questions on SAP UI5 is better asked in SAPUI5 comunity forum
Best Regards
Roy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sridevi,
When the browser gets 401 it will pop up the authentication user/pass dialog
and any client script can't help you on that, as the browser enforce that.
To avoid that you should consider having some deployment on the server, like server form login.
Fiori had their application deployed on the server and then the login could rely on server side code.
Best Regards
Roy
User | Count |
---|---|
85 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.