FusabaseAuth constructor
- {required FusabaseApp app}
Constructs an FusabaseAuth instance.
app The FUSABASE app instance.
Initializes configuration, persistence, and helpers based on app options.
Returns the FusabaseAuth instance.
Example:
final auth = FusabaseAuth(app: myApp);
Implementation
FusabaseAuth({required this.app})
: options = app.options,
__logLevel = app.logLevel,
config = getConfig(app),
_persistenceManager = PersistenceManager(
name: "${app.options.appID}_AUTH_STORE",
),
_authHelper =
app.config?.authType == 'base' || app.config?.authType == 'ldap'
? ONPREMAuthHelper(
options: app.options,
config: getConfig(app),
logLevel: app.logLevel,
)
: IDCSAuthHelper(
options: app.options,
config: getConfig(app),
logLevel: app.logLevel,
) {
_authHelper._setApp(app);
_initFuture = __initialLogin();
if (kIsWeb) {
void handleMessage(dynamic data) {
try {
dynamic message = jsonDecode(data);
if (message["name"] == "${app.options.appID}localLogin") {
_handleLocalLogin(message["at"], message["rt"]);
} else if (message["name"] == "${app.options.appID}indexedDBLogin") {
_handleIndexedDBLogin(message["at"], message["rt"]);
} else if (message["name"] == "${app.options.appID}otherLogin") {
_handleOtherLogin();
} else if (message["name"] == "${app.options.appID}localLogout") {
_handleLogout();
}
} catch (e) {}
}
_initFuture
.whenComplete(() {
_persistenceManager.listener.onMessage.listen((dynamic event) {
handleMessage(event.data);
});
})
.catchError((_) {
// Startup errors are still surfaced through _initFuture awaiters.
});
}
}