feat: 切换邮箱认证并重构前后端启动与门禁
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
class ApiProblem implements Exception {
|
||||
ApiProblem({
|
||||
required this.status,
|
||||
required this.title,
|
||||
required this.detail,
|
||||
this.code,
|
||||
});
|
||||
|
||||
final int status;
|
||||
final String title;
|
||||
final String detail;
|
||||
final String? code;
|
||||
|
||||
String toUserMessage() {
|
||||
return 'Request failed';
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return toUserMessage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import '../../l10n/app_localizations.dart';
|
||||
import 'api_problem.dart';
|
||||
|
||||
String mapApiProblemToMessage(ApiProblem problem, AppLocalizations l10n) {
|
||||
switch (problem.code) {
|
||||
case 'AUTH_TOO_MANY_REQUESTS':
|
||||
return l10n.errorTooManyRequests;
|
||||
case 'AUTH_VERIFICATION_CODE_INVALID':
|
||||
return l10n.errorInvalidVerificationCode;
|
||||
case 'AUTH_REFRESH_TOKEN_INVALID':
|
||||
return l10n.errorSessionExpired;
|
||||
case 'AUTH_SERVICE_UNAVAILABLE':
|
||||
return l10n.errorServiceUnavailable;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (problem.status >= 500) {
|
||||
return l10n.errorServerGeneric;
|
||||
}
|
||||
return l10n.errorRequestGeneric;
|
||||
}
|
||||
Reference in New Issue
Block a user