mirror of
https://github.com/inventree/inventree-app.git
synced 2026-11-17 03:14:49 +00:00
* use session auth rather than token auth * Add unit tests for login * Ensure user cannot reuse login after logout * handle logout mid session * Additional unit tests * ensure sensitive data is redacted from sentry * Handle session disconnect * Additional tweaks * Update pubspec.lock * Update release_notes.md * Bump version number * Adjust login button * Clear stored session when host changes * Improved redacting of sensitive info * Improved handling of local session storage * prevent failed migration from logging as complete * Fix for error raised in overlapping requests * replace userInfo on successful response * handle empty response * Improved session comparison * Add UI testing
44 lines
1.1 KiB
Dart
44 lines
1.1 KiB
Dart
import "package:inventree/auth/allauth_client.dart";
|
|
import "package:inventree/auth/auth_result.dart";
|
|
|
|
/*
|
|
* A method for starting a login against the server.
|
|
*
|
|
* Each method only performs the *initial* authentication step -
|
|
* any subsequent flows (e.g. MFA) are handled by InvenTreeAuth,
|
|
* regardless of how the login was started.
|
|
*
|
|
* Future SSO support adds a ProviderAuthMethod which obtains a token
|
|
* from the provider and calls AllauthClient.loginProviderToken()
|
|
*/
|
|
abstract class AuthMethod {
|
|
const AuthMethod();
|
|
|
|
// Username to remember against the profile once login succeeds (if any)
|
|
String get username => "";
|
|
|
|
Future<AuthResult> authenticate(AllauthClient client, AuthConfig config);
|
|
}
|
|
|
|
/*
|
|
* Login with username (or email) and password
|
|
*/
|
|
class PasswordAuthMethod extends AuthMethod {
|
|
const PasswordAuthMethod(this.login, this.password);
|
|
|
|
final String login;
|
|
final String password;
|
|
|
|
@override
|
|
String get username => login;
|
|
|
|
@override
|
|
Future<AuthResult> authenticate(AllauthClient client, AuthConfig config) {
|
|
return client.loginPassword(
|
|
login: login,
|
|
password: password,
|
|
field: config.loginField,
|
|
);
|
|
}
|
|
}
|