You need to sign in to do that
Don't have an account?

login script not working
Hi friends ... this script not work.. nor displaying logs kindly suggest
Component :-
<aura:component controller="frLoginController"
implements="flexipage:availableForAllPageTypes,lightning:actionOverride,flexipage:availableForAllPageTypes,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:appHostable" >
<ltng:require styles="/resource/SLDS0110/assets/styles/salesforce-lightning-design-system-ltng.css" />
<aura:attribute name="recordId" type="String" />
<aura:registerEvent name="createRecordEvent" type="c:createRecordEvent"/>
<aura:handler event="force:refreshView" action="{!c.isRefreshed}" />
<div class="slds-form-element">
<label class="slds-form-element__label" for="UserName">Username1</label>
<div class="slds-form-element__control">
<input type="text" id="UserName" class="slds-input" value="meera@gmail.com" />
</div>
</div>
<div class="slds-form-element">
<label class="slds-form-element__label" for="password">Password</label>
<div class="slds-form-element__control">
<input type="password" id="Password" class="slds-input" value="123" />
</div>
</div>
<div class="slds-form-element__control">
<button class="slds-button slds-button_brand LoginBtn" label="Login" title="Login" iconPosition = "Left" onclick="{!c.loginChk}">Login</button>
<div class="slds-form-element slds-m-top_small">
<a href="javascript:void(0)" onclick="{!c.createRecord}">Sign Up</a> |
<a href="javascript:void(0)">Forgot Password ?</a>
</div>
</div>
=========================
Controller :-
loginChk : function(component, event, helper)
{
console.log('Controller handle click...');
var Username = component.get("v.Username");
var Password = component.get("v.Password");
action.setParams({Password : Password});
action.setParams({Username : Username});
var action = component.get("c.loginCheck");
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS"){
system.debug('Success');
}else if (state === "ERROR") {
system.debug('Error');
}else{
console.log("Unknown Error") ;
}
});
$A.enqueueAction(action);
},
isRefreshed: function(component, event, helper) {
location.reload();
},
============================
Apex
public class frLoginController {
@AuraEnabled
public static List < FirstCode__FrRegistration__c > loginCheck(String Password,String Username) {
//return [SELECT FirstCode__Password__c,FirstCode__Username__c FROM FirstCode__FrRegistration__c where FirstCode__Password__c=:Password && FirstCode__Username__c=:Username];
return [SELECT FirstCode__Password__c, FirstCode__Username__c FROM FirstCode__FrRegistration__c where FirstCode__Password__c=:Password and FirstCode__Username__c=:Username];
}
}
Component :-
<aura:component controller="frLoginController"
implements="flexipage:availableForAllPageTypes,lightning:actionOverride,flexipage:availableForAllPageTypes,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:appHostable" >
<ltng:require styles="/resource/SLDS0110/assets/styles/salesforce-lightning-design-system-ltng.css" />
<aura:attribute name="recordId" type="String" />
<aura:registerEvent name="createRecordEvent" type="c:createRecordEvent"/>
<aura:handler event="force:refreshView" action="{!c.isRefreshed}" />
<div class="slds-form-element">
<label class="slds-form-element__label" for="UserName">Username1</label>
<div class="slds-form-element__control">
<input type="text" id="UserName" class="slds-input" value="meera@gmail.com" />
</div>
</div>
<div class="slds-form-element">
<label class="slds-form-element__label" for="password">Password</label>
<div class="slds-form-element__control">
<input type="password" id="Password" class="slds-input" value="123" />
</div>
</div>
<div class="slds-form-element__control">
<button class="slds-button slds-button_brand LoginBtn" label="Login" title="Login" iconPosition = "Left" onclick="{!c.loginChk}">Login</button>
<div class="slds-form-element slds-m-top_small">
<a href="javascript:void(0)" onclick="{!c.createRecord}">Sign Up</a> |
<a href="javascript:void(0)">Forgot Password ?</a>
</div>
</div>
=========================
Controller :-
loginChk : function(component, event, helper)
{
console.log('Controller handle click...');
var Username = component.get("v.Username");
var Password = component.get("v.Password");
action.setParams({Password : Password});
action.setParams({Username : Username});
var action = component.get("c.loginCheck");
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS"){
system.debug('Success');
}else if (state === "ERROR") {
system.debug('Error');
}else{
console.log("Unknown Error") ;
}
});
$A.enqueueAction(action);
},
isRefreshed: function(component, event, helper) {
location.reload();
},
============================
Apex
public class frLoginController {
@AuraEnabled
public static List < FirstCode__FrRegistration__c > loginCheck(String Password,String Username) {
//return [SELECT FirstCode__Password__c,FirstCode__Username__c FROM FirstCode__FrRegistration__c where FirstCode__Password__c=:Password && FirstCode__Username__c=:Username];
return [SELECT FirstCode__Password__c, FirstCode__Username__c FROM FirstCode__FrRegistration__c where FirstCode__Password__c=:Password and FirstCode__Username__c=:Username];
}
}
are you getting any error on the UI? Try to set console.log in multiple places of a client-side controller and confirm which line you are seeing an issue.
For this requirement, I recommend returning 'record exists' or any other attribute from apex code to the client-side controller. based on the attribute value add your condition check for further logic.
Naveen
console.log('Controller handle click...');
then it is a problem with the click handler. in case if you are seeing the above one in the console, keep the console.log in multiple places and see the output.
Naveen
Obaid, always use lightning base components, replace <input tags with <lightning:input.
I am able to get the button handler at the controller side. attaching the alert message here.
Tested code.
UI
Controller
add alerts or console.log at different places and check the output from apex
Naveen
Thanks bro.. yes it works .. but now i am having friend.app and map this page with that app through lightning app builder ...and now when trying to access this using that it doesnt ...please suggest
Naveen
Team codengine.in