Overview

OwnID Elite offers fully guided, secure, and streamlined webview screens for authentication. They can be easily customized with your brand’s look and feel.

Prerequisites

Implementation

Elite provides pre-built webview authentication screens that can be easily customized. Implementation involves creating providers and setting up event handlers.

Providers Setup

Providers allow you to define how users are authenticated, how sessions are maintained and how accounts are managed within the application. All providers use async/await functions.

Create the following providers:

  • Session Provider: Manages user session creation.
  • Account Provider: Handles account creation. If you want to handle account creation on your own, skip this provider. You will use the onAccountNotFound event handler explained later in this guide.
  • Authentication Provider: Manages various authentication mechanisms, including Password-based authentication provider.

Here’s an example of providers setup:

OwnID.providers {
    $0.session {
        $0.create { loginId, session, authToken, authMethod in
            // Create a user session using the provided data and return an AuthResult indicating success or failure.
        }
    }
    $0.account { // Skip if using your own registration UI!
        $0.register { loginId, profile, ownIdData, authToken in
            // Register a new account with the given loginId and profile data.
            // Set ownIdData to the user profile if available.
            // Return an AuthResult indicating the outcome of the registration.
        }
    }
    $0.auth {
        $0.password {
            $0.authenticate { loginId, password in
                // Authenticate the user with the provided loginId and password.
                // Return an AuthResult to indicate success or failure.
            }
        }
    }
}

Check an example of OwnID.providers implementation here

Start Authentication

To start the authentication flow, call the start function. You can define event handlers for specific actions and responses within the authentication flow. They allow to customize behavior when specific events occur. All event handlers are optional.

OwnID.start {
    $0.events { // All event handlers are optional.
        $0.onNativeAction { name, params in
            // Called when a native action is requested by other event handlers, such as `onAccountNotFound`.
            // Elite UI is currently closed or will be closed in a moment.
            // Run native actions such as user registration.
        }
        $0.onAccountNotFound { loginId, ownIdData, authToken in
            // Called when the specified account details do not match any existing accounts.
            // Call your own registration logic or UI. 
            // Return OwnID.PageAction.close to close the OwnID auth screen and continue.
            OwnID.PageAction.close
        }
        $0.onFinish { loginId, authMethod, authToken in
            // Called when the authentication flow successfully completes.
            // Elite UI is currently closed or will be closed in a moment.
            // Define post-authentication actions here, such as session management or navigation.
        }
        $0.onError { error in
            // Called when an error occurs during the authentication flow.
            // Elite UI is currently closed or will be closed in a moment.
            // Handle errors gracefully, such as logging or showing a message to the user.
        }
        $0.onClose {
            // Called when the authentication flow is closed, either by the user or automatically.
            // Elite UI is currently closed or will be closed in a moment.
            // Define any cleanup or UI updates needed.
        }
    }
}

Check an example of OwnID.start implementation here

Was this page helpful?