You need to sign in to do that
Don't have an account?
k sfdc
How to test below login page class?
public class LoginController {
public PageReference doUsername() {
pageReference ref=new pageReference('/apex/usernamepage');
return ref.setRedirect(true);
}
public String password { get; set; }
public String username { get; set; }
public List<objject__c> lstcon{get; set;}
public LoginController()
{
lstcon=new List<object__c>();
}
public PageReference login() {
try{
Contact con = [Select id, username__c, password__c from object__c
where username__c=:username AND password__C=:password];
if(password == con.Password__c && username == con.username__C ){
pagereference ref = new pagereference('/apex/Fieldssearchpage?conid='+con.id);
return ref.setRedirect(true);
}
else {
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.Fatal,'Invalid Credentials..');
ApexPages.addMessage(msg);
}
}
catch(exception e){
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.Fatal,'No Record Exists in our database...');
ApexPages.addMessage(msg);
}
return null;
}
}
please help me.............
public PageReference doUsername() {
pageReference ref=new pageReference('/apex/usernamepage');
return ref.setRedirect(true);
}
public String password { get; set; }
public String username { get; set; }
public List<objject__c> lstcon{get; set;}
public LoginController()
{
lstcon=new List<object__c>();
}
public PageReference login() {
try{
Contact con = [Select id, username__c, password__c from object__c
where username__c=:username AND password__C=:password];
if(password == con.Password__c && username == con.username__C ){
pagereference ref = new pagereference('/apex/Fieldssearchpage?conid='+con.id);
return ref.setRedirect(true);
}
else {
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.Fatal,'Invalid Credentials..');
ApexPages.addMessage(msg);
}
}
catch(exception e){
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.Fatal,'No Record Exists in our database...');
ApexPages.addMessage(msg);
}
return null;
}
}
please help me.............
you can refer below code:
If this solves your problem, kindly mark it as the best answer.
Thanks,
Vatsal