Skip to main content
The Sales Management App provides a comprehensive authentication system with role-based access control for two distinct user types: Sales Managers and Salespersons.

User Roles

The app supports two primary user roles, each with distinct permissions and capabilities:

Sales Manager

Full team oversight with inventory management, team analytics, and communication tools

Salesperson

Personal dashboard with inventory tracking, sales logging, and performance metrics

Registration Flow

Manager Registration

Sales Managers can create an account with the following information:
1

Access Registration

From the login screen, tap “Sign up as a Manager” to navigate to the manager registration form.The SignUpSalesManager activity handles the registration process at Registration/SignUpSalesManager.java:37.
2

Complete Required Fields

Enter all required information:
  • Full Name
  • Email Address
  • Mobile Number (validated format)
  • Organization Name
  • Password (minimum 6 characters)
All fields are validated before submission. Email and phone numbers must be in valid formats.
3

Account Creation

The system performs several validations:
// Email validation
if(!isValidEmail(email)){
    Toast.makeText(getApplicationContext(), "Invalid email !!", Toast.LENGTH_SHORT).show();
    return;
}

// Password length check
if (password.length() < 6) {
    Toast.makeText(getApplicationContext(), "Password too short, enter minimum 6 characters!", Toast.LENGTH_SHORT).show();
    return;
}
Source: SignUpSalesManager.java:119-122
4

Firebase Authentication

The app creates your account in Firebase Authentication and stores your profile in the Firebase Realtime Database:
SalesManager salesManager = new SalesManager(name, num, password, email, org);
databaseRef = FirebaseDatabase.getInstance().getReference("Manager");
String key = databaseRef.push().getKey();
databaseRef.child(key).setValue(salesManager);
Source: SignUpSalesManager.java:141-145
5

Session Creation

Upon successful registration, a session is created using SharedPreferences:
SessionManager sessionManager = new SessionManager(getApplicationContext());
sessionManager.createLoginSession(key,"Manager");
You’re automatically redirected to the Manager dashboard at ManagerMain.java:248.

Salesperson Registration

Salespersons register by connecting to an existing Sales Manager:
1

Access Registration

From the login screen, tap “Sign up as a Salesperson” to open the salesperson registration form.
2

Enter Details and Manager Name

Complete all required fields including:
  • Full Name
  • Email Address
  • Mobile Number
  • Manager Name (must match an existing manager)
  • Password
The Manager Name must exactly match an existing manager’s name in the system. Registration will fail if the manager doesn’t exist.
3

Manager Verification

The system verifies the manager exists:
databaseRef = FirebaseDatabase.getInstance().getReference("Manager");
databaseRef.addListenerForSingleValueEvent(new ValueEventListener() {
    @Override
    public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
        int x=0;
        for(DataSnapshot dataSnapshot1: dataSnapshot.getChildren()){
            SalesManager salesManager = dataSnapshot1.getValue(SalesManager.class);
            if(salesManager.getName().equals(managerName)){
                x=1;
                break;
            }
        }
        if(x == 0){
            Toast.makeText(getApplicationContext(),"This Manager does not exist !!", Toast.LENGTH_LONG).show();
        }
    }
});
Source: SignUpSalesperson.java:143-159
4

Inventory Initialization

When you join a team, the manager’s inventory items are automatically copied to your account:
InventoryItem itNew = new InventoryItem(
    it.getItemName(),
    it.getTotal_available() - it.getSold(), 
    0, 
    it.getProfit()
);
databaseReference1.child("Inventory").child(key).setValue(itNew);
Source: SignUpSalesperson.java:223-224
5

Leaderboard Entry

A leaderboard entry is created with your registration timestamp:
Long tsLong = System.currentTimeMillis()/1000;
String ts = tsLong.toString();
LeaderBoardObject leaderBoardObject = new LeaderBoardObject(name, ts);
databaseReference1.child(key1).setValue(leaderBoardObject);
Source: SignUpSalesperson.java:184-188

Login Flow

Accessing Your Account

1

Enter Credentials

On the main login screen (MainActivity), enter:
  • Email address
  • Password
  • Select your role (Manager or Salesperson) using the radio button
2

Authentication

The app authenticates against Firebase:
auth.signInWithEmailAndPassword(email,password)
    .addOnCompleteListener(MainActivity.this, new OnCompleteListener<com.google.firebase.auth.AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<com.google.firebase.auth.AuthResult> task) {
            if (!task.isSuccessful()) {
                if (password.length() < 6) {
                    inputPassword.setError(getString(R.string.minimum_password));
                }
                else {
                    Toast.makeText(MainActivity.this, getString(R.string.auth_failed), Toast.LENGTH_LONG).show();
                }
            }
        }
    });
Source: MainActivity.java:126-139
3

Role Verification

The system verifies your email matches the selected role:
if(RadioButtonSelect(radioGroup_type.getCheckedRadioButtonId()).equals("Manager")){
    databaseRef = FirebaseDatabase.getInstance().getReference("Manager");
    // Verify email exists in Manager collection
}
else{
    databaseRef = FirebaseDatabase.getInstance().getReference("Salesperson");
    // Verify email exists in Salesperson collection
}
Source: MainActivity.java:142-174
If you select the wrong role, you’ll see an error: “This email is not registered as [role]!”
4

Session Management

A session is created with your user ID and role stored locally:
SessionManager sm = new SessionManager(getApplicationContext());
sm.createLoginSession(snapshot.getKey(), "Manager"); // or "Salesperson"
This session persists across app restarts until you logout.

Auto-Login

The app remembers your login state:
if (auth.getCurrentUser() != null) {
    SessionManager sm = new SessionManager(getApplicationContext());
    HashMap<String,String> details = sm.getUserDetails();
    String tmp1 = details.get("id");
    String tmp2 = details.get("role");
    if(!TextUtils.isEmpty(tmp1)&& !TextUtils.isEmpty(tmp2)){
        if(tmp2.equals("Manager")){
            goto_Manager();
        }
        else {
            goto_Salesperson();
        }
    }
}
Source: MainActivity.java:57-72
When you reopen the app, you’re automatically redirected to your dashboard if your session is still active.

Password Recovery

Forgot your password? The app includes a password reset feature:
1

Enter Email

On the login screen, enter your registered email address in the email field.
2

Request Reset

Tap the “Forgot Password” button. The system sends a password reset email:
auth.sendPasswordResetEmail(email)
    .addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {
            if (task.isSuccessful()) {
                Toast.makeText(MainActivity.this, 
                    "We have sent you instructions to reset your password!", 
                    Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(MainActivity.this, 
                    "Failed to send reset email!", 
                    Toast.LENGTH_SHORT).show();
            }
        }
    });
Source: MainActivity.java:228-240
3

Check Email

Check your email inbox for the password reset link from Firebase Authentication.

Profile Management

Both Managers and Salespersons can view and update their profile information through the “My Account” section in the navigation drawer.

Viewing Your Profile

Access your profile by:
  1. Opening the navigation drawer (tap the hamburger menu)
  2. Selecting “My Account”
  3. The AccountManager activity displays your profile information

Data Model

Sales Manager Profile:
public class SalesManager {
    private String name;
    private String number;
    private String password;
    private String email;
    private String organisation;
    
    // Getters and setters
}
Salesperson Profile:
public class SalesPerson {
    private String name;
    private String number;
    private String password;
    private String managerName;
    private String emailId;
    
    // Getters and setters
}

Security Features

  • Minimum 6 characters required
  • Stored securely in Firebase Authentication
  • Password reset available via email
The app validates email format using Android’s Patterns utility:
public static boolean isValidEmail(CharSequence target) {
    return Patterns.EMAIL_ADDRESS.matcher(target).matches();
}
Mobile numbers are validated to ensure proper format:
private boolean isValidMobile(String phone) {
    return android.util.Patterns.PHONE.matcher(phone).matches();
}
User sessions are managed using SharedPreferences with user ID and role stored locally. Sessions persist until explicit logout.
Each role has access to different features:
  • Managers: Team management, global inventory control, analytics
  • Salespersons: Personal inventory, sales tracking, leaderboard

Common Issues

When registering as a Salesperson, ensure you enter the exact name of your manager as they registered. Names are case-sensitive and must match exactly.
Verify you’ve selected the correct role (Manager or Salesperson) that matches how you originally registered.
Passwords must be at least 6 characters long. Use a combination of letters, numbers, and symbols for better security.
Each email can only be used once in the system. Use a different email address or reset your password if you’ve forgotten it.

Best Practices

For Managers

  • Share your exact registered name with your team
  • Use a professional email address
  • Keep your organization name consistent

For Salespersons

  • Verify manager name spelling before submitting
  • Use a unique email address
  • Contact your manager if registration fails

Build docs developers (and LLMs) love