function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
megha patil 16megha patil 16 

log in details in custom field

how can i store log in details in custom filed
Deepali KulshresthaDeepali Kulshrestha
Hi Megha,


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