You need to sign in to do that
Don't have an account?
Mariem Mejrissi
login page in salesforce lightning
I have to create the login page with User name and password in lightning
I have created the fields, but I have this error when I enter invalid password or username.
This page has an error. You might just need to refresh it. Error in $A.getCallback() [Cannot read property 'login__c' of null] Callback failed: apex://LoginController/ACTION$getressource Failing descriptor: {markup://c:login}
Can you please help me in this.
Login controller.js
({
doInit : function(component, event, helper) {
},
loginPage : function(component, event, helper) {
var userid = component.get("v.Empiduser");
var pass= component.get("v.Empidpwd");
var action = component.get("c.getressource");
action.setParams({
username:userid,
userpassw:pass
});
action.setCallback(this,function(response){
if($A.util.isEmpty(userid ) || $A.util.isUndefined(userid )){
alert('Please Enter User Name!');
return ;
}
if($A.util.isEmpty(pass) || $A.util.isUndefined(pass)){
alert('Please Enter Password!');
return;
}
var login= response.getReturnValue().login__c ;
var password= response.getReturnValue().password__c;
var role= response.getReturnValue().Role__c;
if (login==userid && password==pass &&role=="Scrum Master")
{
const myEvent = component.getEvent('firstEvent');
myEvent.setParams({ username: userid });
myEvent.fire();
}
else if ((login==userid && password==pass &&role=="Developer"))
{
const myEvent = component.getEvent('firstEvent');
myEvent.setParams({ username: userid });
myEvent.fire();
}
else if ((login==userid && password==pass &&role=="Product Owner"))
{
const myEvent = component.getEvent('firstEvent');
myEvent.setParams({ username: userid });
myEvent.fire();
}
else
{
alert("echec");
}
});
$A.enqueueAction(action);
},
})
class Apex
public class LoginController {
@auraEnabled
public static Ressource__c getressource(String username,String userpassw ){
return ([SELECT login__c,Name,password__c,Role__c,Tel__c FROM Ressource__c where login__c=:username and password__c=: userpassw]);
}
}
Regards,
Mariem
I have created the fields, but I have this error when I enter invalid password or username.
This page has an error. You might just need to refresh it. Error in $A.getCallback() [Cannot read property 'login__c' of null] Callback failed: apex://LoginController/ACTION$getressource Failing descriptor: {markup://c:login}
Can you please help me in this.
Login controller.js
({
doInit : function(component, event, helper) {
},
loginPage : function(component, event, helper) {
var userid = component.get("v.Empiduser");
var pass= component.get("v.Empidpwd");
var action = component.get("c.getressource");
action.setParams({
username:userid,
userpassw:pass
});
action.setCallback(this,function(response){
if($A.util.isEmpty(userid ) || $A.util.isUndefined(userid )){
alert('Please Enter User Name!');
return ;
}
if($A.util.isEmpty(pass) || $A.util.isUndefined(pass)){
alert('Please Enter Password!');
return;
}
var login= response.getReturnValue().login__c ;
var password= response.getReturnValue().password__c;
var role= response.getReturnValue().Role__c;
if (login==userid && password==pass &&role=="Scrum Master")
{
const myEvent = component.getEvent('firstEvent');
myEvent.setParams({ username: userid });
myEvent.fire();
}
else if ((login==userid && password==pass &&role=="Developer"))
{
const myEvent = component.getEvent('firstEvent');
myEvent.setParams({ username: userid });
myEvent.fire();
}
else if ((login==userid && password==pass &&role=="Product Owner"))
{
const myEvent = component.getEvent('firstEvent');
myEvent.setParams({ username: userid });
myEvent.fire();
}
else
{
alert("echec");
}
});
$A.enqueueAction(action);
},
})
class Apex
public class LoginController {
@auraEnabled
public static Ressource__c getressource(String username,String userpassw ){
return ([SELECT login__c,Name,password__c,Role__c,Tel__c FROM Ressource__c where login__c=:username and password__c=: userpassw]);
}
}
Regards,
Mariem
response.getReturnValue() should be null.
var login= response.getReturnValue().login__c ;
You should test the states of the response (above all SUCCESS and ERROR ) because there is an error.
The messages of the console.log are seen in the Chrome DevTools.
When you want to see logged messages or run JavaScript, press Command+Option+J (Mac) or Control+Shift+J (Windows, Linux, Chrome OS) to jump straight into the Console panel.
https://developers.google.com/web/tools/chrome-devtools
Here is the offending line:
var login= response.getReturnValue().login__c ;
If there is an error, then getReturnValue() is not going to return an object with the login__c field, so it's like you're trying to open the door of a rock. Rock doesn't have a door, so there will be problems.
The previous guy should get the best answer.
From the list of components, click the one you want to customize. ...
On the Lightning component detail page, click Developer Console https://www.tellpopeyes.us/