|
110 | 110 | private SecurityAuthenticationInfo Authentication { get; set; } = SecurityAuthenticationInfo.Unavailable(); |
111 | 111 | private bool AuthenticationAvailable { get; set; } = true; |
112 | 112 | private string Message { get; set; } = ""; |
| 113 | + private string DisplayedOAuthError { get; set; } = ""; |
113 | 114 | private string Destination => SecurityBrowserService.NormalizeReturnUrl(ReturnUrl); |
114 | 115 |
|
115 | 116 | protected override void OnParametersSet() { |
|
118 | 119 | try { |
119 | 120 | Authentication = Security.AuthenticationInfo(); |
120 | 121 | AuthenticationAvailable = true; |
121 | | - Message = string.IsNullOrWhiteSpace(OAuthError) |
122 | | - ? "" |
123 | | - : OAuthErrorMessage(OAuthError); |
| 122 | + if (string.IsNullOrWhiteSpace(OAuthError)) { |
| 123 | + if (!string.IsNullOrWhiteSpace(DisplayedOAuthError)) { |
| 124 | + Message = ""; |
| 125 | + DisplayedOAuthError = ""; |
| 126 | + } |
| 127 | + } else { |
| 128 | + Message = OAuthErrorMessage(OAuthError); |
| 129 | + DisplayedOAuthError = OAuthError; |
| 130 | + } |
124 | 131 | } catch (Exception ex) { |
125 | 132 | Authentication = SecurityAuthenticationInfo.Unavailable(); |
126 | 133 | AuthenticationAvailable = false; |
| 134 | + DisplayedOAuthError = ""; |
127 | 135 | Message = $"Unable to load authentication information: {UserInterfaceMessages.Friendly(ex)}"; |
128 | 136 | } |
129 | 137 |
|
|
153 | 161 | try { |
154 | 162 | var result = await Security.Validate(Input.Username, Input.Password); |
155 | 163 | if (!result.Success) { |
| 164 | + DisplayedOAuthError = ""; |
156 | 165 | Message = result.Message; |
157 | 166 | return; |
158 | 167 | } |
159 | 168 |
|
160 | 169 | var context = HttpContextAccessor.HttpContext; |
161 | 170 | if (context is null) { |
| 171 | + DisplayedOAuthError = ""; |
162 | 172 | Message = "The sign-in response is no longer available."; |
163 | 173 | return; |
164 | 174 | } |
165 | 175 |
|
166 | 176 | UiCredentialCookie.DeleteOAuthToken(context.Response); |
167 | 177 | UiCredentialCookie.AppendBasic(context.Response, new UiCredentials(Input.Username.Trim(), Input.Password)); |
168 | 178 | } catch (OperationCanceledException) { |
| 179 | + DisplayedOAuthError = ""; |
169 | 180 | Message = "Sign-in was canceled."; |
170 | 181 | return; |
171 | 182 | } catch (Exception ex) { |
| 183 | + DisplayedOAuthError = ""; |
172 | 184 | Message = $"Failed to sign in: {UserInterfaceMessages.Friendly(ex)}"; |
173 | 185 | return; |
174 | 186 | } |
|
0 commit comments