|
127 | 127 | private bool _allowsitelogin = true; |
128 | 128 | private bool _allowloginlink = false; |
129 | 129 | private bool _allowpasskeys = false; |
| 130 | + private string _returnurl = string.Empty; |
130 | 131 |
|
131 | 132 | private ElementReference login; |
132 | 133 | private bool validated = false; |
|
169 | 170 | _registerurl = NavigateUrl("register"); |
170 | 171 | } |
171 | 172 |
|
| 173 | + // PageState.ReturnUrl is not specified if user navigated directly to login page |
| 174 | + _returnurl = (!string.IsNullOrEmpty(PageState.ReturnUrl)) ? PageState.ReturnUrl : PageState.Alias.Path; |
| 175 | + |
172 | 176 | _togglepassword = SharedLocalizer["ShowPassword"]; |
173 | 177 |
|
174 | 178 | if (PageState.QueryString.ContainsKey("name")) |
|
216 | 220 | { |
217 | 221 | if (PageState.QueryString.ContainsKey("status")) |
218 | 222 | { |
219 | | - AddModuleMessage(Localizer["ExternalLoginStatus." + PageState.QueryString["status"]], MessageType.Info); |
| 223 | + AddModuleMessage(Localizer["ExternalLoginStatus." + PageState.QueryString["status"]], MessageType.Warning); |
220 | 224 | } |
221 | 225 | } |
222 | 226 | } |
|
252 | 256 |
|
253 | 257 | private void ExternalLogin() |
254 | 258 | { |
255 | | - NavigationManager.NavigateTo(Utilities.TenantUrl(PageState.Alias, "/pages/external?returnurl=" + WebUtility.UrlEncode(PageState.ReturnUrl)), true); |
| 259 | + NavigationManager.NavigateTo(Utilities.TenantUrl(PageState.Alias, "/pages/external?returnurl=" + WebUtility.UrlEncode(_returnurl)), true); |
256 | 260 | } |
257 | 261 |
|
258 | 262 | private void TogglePassword() |
@@ -294,20 +298,17 @@ else |
294 | 298 | { |
295 | 299 | await logger.LogInformation(LogFunction.Security, "Login Successful For {Username} From IP Address {IPAddress}", _username, SiteState.RemoteIPAddress); |
296 | 300 |
|
297 | | - // return url is not specified if user navigated directly to login page |
298 | | - var returnurl = (!string.IsNullOrEmpty(PageState.ReturnUrl)) ? PageState.ReturnUrl : PageState.Alias.Path; |
299 | | - |
300 | 301 | if (hybrid) |
301 | 302 | { |
302 | 303 | // hybrid apps utilize an interactive login |
303 | 304 | var authstateprovider = (IdentityAuthenticationStateProvider)ServiceProvider.GetService(typeof(IdentityAuthenticationStateProvider)); |
304 | 305 | authstateprovider.NotifyAuthenticationChanged(); |
305 | | - NavigationManager.NavigateTo(NavigateUrl(returnurl, true)); |
| 306 | + NavigationManager.NavigateTo(NavigateUrl(_returnurl, true)); |
306 | 307 | } |
307 | 308 | else |
308 | 309 | { |
309 | 310 | // post back to the Login page so that the cookies are set correctly |
310 | | - var fields = new { __RequestVerificationToken = SiteState.AntiForgeryToken, username = _username, password = _password, remember = _remember, returnurl = WebUtility.UrlEncode(returnurl) }; |
| 311 | + var fields = new { __RequestVerificationToken = SiteState.AntiForgeryToken, username = _username, password = _password, remember = _remember, returnurl = WebUtility.UrlEncode(_returnurl) }; |
311 | 312 | string url = Utilities.TenantUrl(PageState.Alias, "/pages/login/"); |
312 | 313 | await interop.SubmitForm(url, fields); |
313 | 314 | } |
@@ -349,14 +350,14 @@ else |
349 | 350 |
|
350 | 351 | private void CancelLogin() |
351 | 352 | { |
352 | | - NavigationManager.NavigateTo(PageState.ReturnUrl); |
| 353 | + NavigationManager.NavigateTo(_returnurl); |
353 | 354 | } |
354 | 355 |
|
355 | 356 | private async Task PasskeyLogin() |
356 | 357 | { |
357 | 358 | // post back to the Passkey page so that the cookies are set correctly |
358 | 359 | var interop = new Interop(JSRuntime); |
359 | | - var fields = new { __RequestVerificationToken = SiteState.AntiForgeryToken, operation = "request", returnurl = NavigateUrl() }; |
| 360 | + var fields = new { __RequestVerificationToken = SiteState.AntiForgeryToken, operation = "request", returnurl = _returnurl }; |
360 | 361 | string url = Utilities.TenantUrl(PageState.Alias, "/pages/passkey/"); |
361 | 362 | await interop.SubmitForm(url, fields); |
362 | 363 | } |
|
423 | 424 | { |
424 | 425 | if (!string.IsNullOrEmpty(_email)) |
425 | 426 | { |
426 | | - if (await UserService.SendLoginLinkAsync(_email)) |
| 427 | + if (await UserService.SendLoginLinkAsync(_email, _returnurl)) |
427 | 428 | { |
428 | 429 | AddModuleMessage(Localizer["Message.SendLoginLink"], MessageType.Info); |
429 | 430 | await logger.LogInformation(LogFunction.Security, "Login Link Sent To Email {Email}", _email); |
|
457 | 458 | if (!string.IsNullOrEmpty(credential)) |
458 | 459 | { |
459 | 460 | // post back to the Passkey page so that the cookies are set correctly |
460 | | - var returnurl = (!string.IsNullOrEmpty(PageState.ReturnUrl)) ? PageState.ReturnUrl : PageState.Alias.Path + "/"; |
461 | | - var fields = new { __RequestVerificationToken = SiteState.AntiForgeryToken, operation = "login", credential = credential, returnurl = returnurl }; |
| 461 | + var fields = new { __RequestVerificationToken = SiteState.AntiForgeryToken, operation = "login", credential = credential, returnurl = _returnurl }; |
462 | 462 | string url = Utilities.TenantUrl(PageState.Alias, "/pages/passkey/"); |
463 | 463 | await interop.SubmitForm(url, fields); |
464 | 464 | } |
|
497 | 497 | // redirect logged in user to specified page |
498 | 498 | if (PageState.User != null && !UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin)) |
499 | 499 | { |
500 | | - NavigationManager.NavigateTo(PageState.ReturnUrl); |
| 500 | + NavigationManager.NavigateTo(_returnurl); |
501 | 501 | } |
502 | 502 | } |
503 | 503 | } |
0 commit comments