forked from baron/baron-sso
c489c7c3 기준 병합 code-check 오류 수정
This commit is contained in:
@@ -31,6 +31,14 @@ class AuthTokenStore {
|
||||
authTokenStore.setPendingProvider(null);
|
||||
}
|
||||
|
||||
static void skipNextCookieSessionCheck() {
|
||||
authTokenStore.skipNextCookieSessionCheck();
|
||||
}
|
||||
|
||||
static bool consumeSkipCookieSessionCheck() {
|
||||
return authTokenStore.consumeSkipCookieSessionCheck();
|
||||
}
|
||||
|
||||
static void clear() {
|
||||
authTokenStore.clear();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ class AuthTokenStoreBackend {
|
||||
static const _providerKey = 'baron_auth_provider';
|
||||
static const _cookieModeKey = 'baron_auth_cookie_mode';
|
||||
static const _pendingProviderKey = 'baron_auth_pending_provider';
|
||||
static const _skipCookieSessionCheckKey =
|
||||
'baron_auth_skip_cookie_session_check';
|
||||
|
||||
final List<AuthTokenStorageTarget> _targets;
|
||||
|
||||
@@ -41,6 +43,14 @@ class AuthTokenStoreBackend {
|
||||
|
||||
String? getPendingProvider() => _readFirst(_pendingProviderKey);
|
||||
|
||||
bool consumeSkipCookieSessionCheck() {
|
||||
final shouldSkip = _readFirst(_skipCookieSessionCheckKey) == '1';
|
||||
if (shouldSkip) {
|
||||
_removeAll(_skipCookieSessionCheckKey);
|
||||
}
|
||||
return shouldSkip;
|
||||
}
|
||||
|
||||
void setPendingProvider(String? provider) {
|
||||
if (provider == null || provider.isEmpty) {
|
||||
_removeAll(_pendingProviderKey);
|
||||
@@ -54,6 +64,11 @@ class AuthTokenStoreBackend {
|
||||
_removeAll(_providerKey);
|
||||
_removeAll(_cookieModeKey);
|
||||
_removeAll(_pendingProviderKey);
|
||||
_removeAll(_skipCookieSessionCheckKey);
|
||||
}
|
||||
|
||||
void skipNextCookieSessionCheck() {
|
||||
_writeAll(_skipCookieSessionCheckKey, '1');
|
||||
}
|
||||
|
||||
String? _readFirst(String key) {
|
||||
|
||||
@@ -3,6 +3,7 @@ class AuthTokenStore {
|
||||
String? _provider;
|
||||
bool _cookieMode = false;
|
||||
String? _pendingProvider;
|
||||
bool _skipCookieSessionCheck = false;
|
||||
|
||||
String? getToken() => _token;
|
||||
|
||||
@@ -26,15 +27,26 @@ class AuthTokenStore {
|
||||
|
||||
String? getPendingProvider() => _pendingProvider;
|
||||
|
||||
bool consumeSkipCookieSessionCheck() {
|
||||
final shouldSkip = _skipCookieSessionCheck;
|
||||
_skipCookieSessionCheck = false;
|
||||
return shouldSkip;
|
||||
}
|
||||
|
||||
void setPendingProvider(String? provider) {
|
||||
_pendingProvider = provider;
|
||||
}
|
||||
|
||||
void skipNextCookieSessionCheck() {
|
||||
_skipCookieSessionCheck = true;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_token = null;
|
||||
_provider = null;
|
||||
_cookieMode = false;
|
||||
_pendingProvider = null;
|
||||
_skipCookieSessionCheck = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,8 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
String _verificationTitleKey = 'ui.userfront.login.verification.title';
|
||||
String _verificationPageTitleKey =
|
||||
'ui.userfront.login.verification.page_title';
|
||||
String _verificationActionLabelKey =
|
||||
'ui.userfront.login.verification.action_label';
|
||||
Timer? _verificationRedirectTimer;
|
||||
bool _noticeHandled = false;
|
||||
bool _drySendEnabled = false;
|
||||
@@ -142,7 +144,8 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
_markVerificationApproved(
|
||||
'msg.userfront.login.verification.approved_remote',
|
||||
titleKey: 'ui.userfront.login.verification.title_remote',
|
||||
onAction: _closeVerificationWindowIfPossible,
|
||||
actionLabelKey: 'ui.userfront.login.verification.action_label_remote',
|
||||
onAction: _moveToSigninOrCloseVerificationWindow,
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -279,6 +282,12 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
}
|
||||
|
||||
Future<void> _tryCookieSession({bool silent = true}) async {
|
||||
if (AuthTokenStore.consumeSkipCookieSessionCheck()) {
|
||||
debugPrint(
|
||||
"[Auth] Skipping one cookie session check after verification handoff.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
final loginChallenge = _loginChallenge;
|
||||
final token = AuthTokenStore.getToken();
|
||||
if (!shouldPromoteCookieSession(
|
||||
@@ -798,7 +807,12 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
}
|
||||
final localeCode =
|
||||
extractLocaleFromPath(Uri.base) ?? resolvePreferredLocaleCode();
|
||||
webWindow.redirectTo(buildLocalizedVerificationCompletePath(localeCode));
|
||||
final target = buildLocalizedVerificationCompletePath(localeCode);
|
||||
if (mounted) {
|
||||
context.go(target);
|
||||
} else {
|
||||
webWindow.redirectTo(target);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -806,6 +820,7 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
String messageKey, {
|
||||
String? titleKey,
|
||||
String? pageTitleKey,
|
||||
String? actionLabelKey,
|
||||
String actionPath = '/',
|
||||
bool autoRedirect = false,
|
||||
Duration redirectDelay = const Duration(seconds: 2),
|
||||
@@ -822,6 +837,8 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
titleKey ?? 'ui.userfront.login.verification.title';
|
||||
_verificationPageTitleKey =
|
||||
pageTitleKey ?? 'ui.userfront.login.verification.page_title';
|
||||
_verificationActionLabelKey =
|
||||
actionLabelKey ?? 'ui.userfront.login.verification.action_label';
|
||||
_onVerificationAction = onAction;
|
||||
});
|
||||
_verificationRedirectTimer?.cancel();
|
||||
@@ -847,6 +864,15 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
webWindow.close();
|
||||
}
|
||||
|
||||
void _moveToSigninOrCloseVerificationWindow() {
|
||||
if (webWindow.hasOpener()) {
|
||||
webWindow.close();
|
||||
return;
|
||||
}
|
||||
AuthTokenStore.skipNextCookieSessionCheck();
|
||||
context.go(buildLocalizedSigninPath(Uri.base));
|
||||
}
|
||||
|
||||
void _handleVerificationResultPrimaryAction() {
|
||||
if (_onVerificationAction != null) {
|
||||
_runVerificationExitAction();
|
||||
@@ -875,7 +901,8 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
_markVerificationApproved(
|
||||
'msg.userfront.login.verification.approved_remote',
|
||||
titleKey: 'ui.userfront.login.verification.title_remote',
|
||||
onAction: _closeVerificationWindowIfPossible,
|
||||
actionLabelKey: 'ui.userfront.login.verification.action_label_remote',
|
||||
onAction: _moveToSigninOrCloseVerificationWindow,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -890,13 +917,9 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
);
|
||||
final verificationTitle = tr(_verificationTitleKey);
|
||||
final closeHint = tr('msg.userfront.login.verification.close_hint');
|
||||
final showCloseHint = _onVerificationAction != null || _verificationOnly;
|
||||
final actionLabelKey = showCloseHint
|
||||
? 'ui.userfront.login.verification.action_label_close'
|
||||
: 'ui.userfront.login.verification.action_label';
|
||||
final actionIcon = showCloseHint
|
||||
? Icons.close_rounded
|
||||
: Icons.arrow_forward_rounded;
|
||||
final showCloseHint =
|
||||
_verificationActionLabelKey ==
|
||||
'ui.userfront.login.verification.action_label_close';
|
||||
|
||||
return SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
@@ -1001,11 +1024,13 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: FilledButton.icon(
|
||||
child: FilledButton(
|
||||
onPressed:
|
||||
_handleVerificationResultPrimaryAction,
|
||||
icon: Icon(actionIcon),
|
||||
label: Text(tr(actionLabelKey)),
|
||||
child: Text(
|
||||
tr(_verificationActionLabelKey),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1027,7 +1052,7 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
Wrap(
|
||||
const Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
@@ -1116,6 +1141,10 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
}
|
||||
|
||||
if (jwt is String && jwt.isNotEmpty) {
|
||||
if (_verificationOnly) {
|
||||
_markRemoteVerificationApproved();
|
||||
return;
|
||||
}
|
||||
if (hasLocalSession) {
|
||||
_markVerificationApproved(
|
||||
'msg.userfront.login.verification.approved_local',
|
||||
@@ -2367,7 +2396,7 @@ class _LoginScreenState extends ConsumerState<LoginScreen>
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Wrap(
|
||||
const Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
|
||||
@@ -342,6 +342,8 @@ const Map<String, String> koStrings = {
|
||||
"msg.common.requesting": "요청 중...",
|
||||
"msg.common.saving": "저장 중...",
|
||||
"msg.common.unknown_error": "알 수 없는 오류",
|
||||
"msg.dev.audit.access_denied": "감사 로그는 개발자 권한이 있어야 볼 수 있습니다.",
|
||||
"msg.dev.audit.access_denied_detail": "개발자 권한 신청 페이지에서 신청을 등록한 뒤 승인을 받아주세요.",
|
||||
"msg.dev.audit.empty": "조회된 감사 로그가 없습니다.",
|
||||
"msg.dev.audit.forbidden": "감사 로그를 조회할 권한이 없습니다. 관리자에게 권한을 요청해주세요.",
|
||||
"msg.dev.audit.load_error": "감사 로그 조회 실패: {{error}}",
|
||||
@@ -730,8 +732,7 @@ const Map<String, String> koStrings = {
|
||||
"msg.userfront.login.verification.approved": "승인되었습니다. 로그인은 요청하신 창에서 완료됩니다.",
|
||||
"msg.userfront.login.verification.approved_local":
|
||||
"승인 되었습니다. 이 기기는 로그인되어 있는 상태입니다. 원격 창도 로그인이 될 예정입니다",
|
||||
"msg.userfront.login.verification.approved_remote":
|
||||
"승인되었습니다.\n로그인 요청하신 화면으로 돌아가주세요.",
|
||||
"msg.userfront.login.verification.approved_remote": "요청하신 로그인이 완료되었습니다",
|
||||
"msg.userfront.login.verification.close_hint": "이 창은 이제 닫으셔도 됩니다.",
|
||||
"msg.userfront.login.verification.pending_remote":
|
||||
"승인 요청을 확인하고 있습니다. 잠시만 기다려 주세요.",
|
||||
@@ -2199,6 +2200,7 @@ const Map<String, String> koStrings = {
|
||||
"ui.userfront.login.unregistered.title": "미등록 회원",
|
||||
"ui.userfront.login.verification.action_label": "확인",
|
||||
"ui.userfront.login.verification.action_label_close": "창 닫기",
|
||||
"ui.userfront.login.verification.action_label_remote": "로그인 창으로 이동하기",
|
||||
"ui.userfront.login.verification.page_title": "Baron SW 포탈",
|
||||
"ui.userfront.login.verification.title": "승인 완료",
|
||||
"ui.userfront.login.verification.title_pending": "로그인 승인 확인 중",
|
||||
@@ -2693,6 +2695,10 @@ const Map<String, String> enStrings = {
|
||||
"msg.common.requesting": "Requesting...",
|
||||
"msg.common.saving": "Saving...",
|
||||
"msg.common.unknown_error": "unknown error",
|
||||
"msg.dev.audit.access_denied":
|
||||
"Audit logs are available only to users with developer access.",
|
||||
"msg.dev.audit.access_denied_detail":
|
||||
"Submit a request on the developer access page and wait for approval.",
|
||||
"msg.dev.audit.empty": "No audit logs found.",
|
||||
"msg.dev.audit.forbidden":
|
||||
"You do not have permission to view audit logs. Please request access from an administrator.",
|
||||
@@ -3156,7 +3162,7 @@ const Map<String, String> enStrings = {
|
||||
"msg.userfront.login.verification.approved_local":
|
||||
"Approved. This device is already signed in, and the remote window will be signed in shortly.",
|
||||
"msg.userfront.login.verification.approved_remote":
|
||||
"Approved.\nPlease return to the screen where you requested sign-in.",
|
||||
"Your requested sign-in is complete.",
|
||||
"msg.userfront.login.verification.close_hint":
|
||||
"You can close this window now.",
|
||||
"msg.userfront.login.verification.pending_remote":
|
||||
@@ -4704,6 +4710,7 @@ const Map<String, String> enStrings = {
|
||||
"ui.userfront.login.unregistered.title": "Account not found",
|
||||
"ui.userfront.login.verification.action_label": "Done",
|
||||
"ui.userfront.login.verification.action_label_close": "Close Window",
|
||||
"ui.userfront.login.verification.action_label_remote": "Go to sign-in window",
|
||||
"ui.userfront.login.verification.page_title": "Baron SW Portal",
|
||||
"ui.userfront.login.verification.title": "Approval complete",
|
||||
"ui.userfront.login.verification.title_pending": "Checking approval",
|
||||
|
||||
Reference in New Issue
Block a user