function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
I went through your problem you can refer below code:
Aura component:-
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="LoginPageClass">
<aura:attribute name = "Empiduser" type = "String"/>
<aura:attribute name = "Empidpwd" type = "String"/>
<div class="slds-form-element slds-align_absolute-center slds-m-top_x-large">
<div class="slds-col slds-size_6-of-12">
<form>
<div class="slds-align_absolute-center slds-m-top_small slds-text-heading_large">
<span>Login Page</span>
</div>
<div class="slds-form-element__control">
<lightning:input label="User Name" name="abc" id="username" placeholder="User Name" value="{!v.Empiduser}" />
</div>
<div class="slds-form-element__control">
<lightning:input label="Password" type="password" name="abc" id="password" placeholder="Password" value="{!v.Empidpwd}" />
</div>
<div class="slds-align_absolute-center" style="height:4rem">
<lightning:button variant="success" label="Login" onclick="{!c.loginPage}"/>
</div>
</form>
</div>
</div>
</aura:component>
Js Controller:-
({
loginPage : function(component, event, helper) {
var action = component.get("c.getcontact");
var testid = component.get("v.Empiduser");
var testpw = component.get("v.Empidpwd");
if($A.util.isEmpty(testid) || $A.util.isUndefined(testid)){
alert('Please Enter User Name!');
return;
}
if($A.util.isEmpty(testpw) || $A.util.isUndefined(testpw)){
alert('Please Enter Password!');
return;
}
action.setParams({
username:testid,
userpassw:testpw
});
action.setCallback(this,function(a){
var rtnValue = a.getReturnValue();
alert(rtnValue);
console.log('The field list is :'+JSON.stringify(a.getReturnValue()));
});
$A.enqueueAction(action);
component.set("v.testid",'');
component.set("v.testpw",'');
}
})
Apex Class:-
public class LoginPageClass {
@auraEnabled
public static String getcontact(String username,String userpassw ){
List<Contact> lcont=new List<Contact>([select Username__c,Password__c from Contact where Username__c=:username Limit 1]);
if(lcont.size()==0){
return 'User dose not exit!';
}
else{
if(lcont[0].Password__c==userpassw ){
return 'Login successfully';
}
else{
return 'Invalid Password';
}
}
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com