Skip to main content
Version: Next

Logging in and out Vipaso Customer and Business users

This guide shows how to implement login/logout flows for both Customer and Business users using the Android SDK.

Prerequisites

Customer — Login

Authenticate a customer user with identifier (email or phone) and password. The SDK securely stores the session.

Important: Only call this method when the customer is not authenticated. Check authentication state first using Vipaso.user.customer.isAuthenticated().

// First check if already authenticated
if (!Vipaso.user.customer.isAuthenticated()) {
val loginRequest = LoginRequest(
identifier = "user@example.com", // email or phone
password = "secure_password"
)

try {
Vipaso.user.customer.login(loginRequest)
// Success: user can now access Customer features
} catch (e: Throwable) {
// Handle authentication error
}
}

Customer — Logout

Vipaso.user.customer.logout()

Customer — Authentication State

Observe whether the customer is authenticated.

Vipaso.user.customer.isAuthenticated()
.collect { authenticated ->
if (authenticated) {
// Show main app content
} else {
// User is not logged in, show login screen
}
}

Business — Login

Authenticate a business user with identifier (email or phone) and password. The SDK securely stores the session.

Important: Only call this method when the business is not authenticated. Check authentication state first using Vipaso.user.business.isAuthenticated().

// First check if already authenticated
if (!Vipaso.user.business.isAuthenticated()) {
val loginRequest = LoginRequest(
identifier = "business@example.com", // email or phone
password = "securePassword"
)

try {
Vipaso.user.business.login(loginRequest)
// Success: user can now access Business features
} catch (e: Throwable) {
// Handle authentication error
}
}

Business — Logout

Vipaso.user.business.logout()

Business — Authentication State

Vipaso.user.business.isAuthenticated()
.collect { authenticated ->
if (authenticated) {
// Show main app content
} else {
// User is not logged in, show login screen
}
}