38 lines
882 B
Dart
38 lines
882 B
Dart
|
|
import 'package:guru_app/property/app_property.dart';
|
||
|
|
import 'package:guru_utils/auth/auth_credential_manager.dart';
|
||
|
|
|
||
|
|
class AnonymousCredential extends Credential {
|
||
|
|
final String secretKey;
|
||
|
|
|
||
|
|
AnonymousCredential(this.secretKey);
|
||
|
|
|
||
|
|
@override
|
||
|
|
String get token => secretKey;
|
||
|
|
|
||
|
|
@override
|
||
|
|
AuthType get authType => AuthType.anonymous;
|
||
|
|
|
||
|
|
String toJson() => secretKey;
|
||
|
|
}
|
||
|
|
|
||
|
|
class AnonymousCredentialDelegate extends AuthCredentialDelegate {
|
||
|
|
const AnonymousCredentialDelegate();
|
||
|
|
|
||
|
|
@override
|
||
|
|
AuthType get authType => AuthType.anonymous;
|
||
|
|
|
||
|
|
@override
|
||
|
|
Future<AuthResult> login() async {
|
||
|
|
final secretKey = await AppProperty.getInstance().getAnonymousSecretKey();
|
||
|
|
return AuthResult.success(AnonymousCredential(secretKey));
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
Future logout() async {}
|
||
|
|
|
||
|
|
@override
|
||
|
|
Credential deserializeCredential(String data) {
|
||
|
|
return AnonymousCredential(data);
|
||
|
|
}
|
||
|
|
}
|