似乎的AccountController(ABP 2.3標準模板版本)發送錯誤信息到客戶端瀏覽器例如當:GetLoginResultAsync發送錯誤信息到客戶端
- 用戶類型錯誤的憑證;
- 用戶名不存在;
用戶市場爲「無效」;
switch (loginResult.Result) { case AbpLoginResultType.Success: return loginResult; default: throw CreateExceptionForFailedLoginAttempt(loginResult.Result, usernameOrEmailAddress, tenancyName); }
例如,CreateExceptionForFailedLoginAttempt回報UserFriendlyException異常,當AbpLoginResultType.UserIsNotActive爲真(用戶閒置),但客戶端收到一個通用的「發生錯誤 - 錯誤!沒有詳細的服務器發送 「消息,而不是‘友好的消息,’
private Exception CreateExceptionForFailedLoginAttempt(AbpLoginResultType result, string usernameOrEmailAddress, string tenancyName)
{
switch (result)
{
case AbpLoginResultType.Success:
return new ApplicationException("Don't call this method with a success result!");
case AbpLoginResultType.InvalidUserNameOrEmailAddress:
// Wrong Username/password
return new UserFriendlyException(L("LoginFailed"), L("UnknownUser"));
case AbpLoginResultType.InvalidPassword:
return new UserFriendlyException(L("LoginFailed"), L("InvalidUserNameOrPassword"));
case AbpLoginResultType.InvalidTenancyName:
return new UserFriendlyException(L("LoginFailed"), L("ThereIsNoTenantDefinedWithName{0}", tenancyName));
case AbpLoginResultType.TenantIsNotActive:
return new UserFriendlyException(L("LoginFailed"), L("TenantIsNotActive", tenancyName));
case AbpLoginResultType.UserIsNotActive:
return new UserFriendlyException(L("LoginFailed"), L("UserIsNotActiveAndCanNotLogin", usernameOrEmailAddress));
case AbpLoginResultType.UserEmailIsNotConfirmed:
return new UserFriendlyException(L("LoginFailed"), "UserEmailIsNotConfirmedAndCanNotLogin");
case AbpLoginResultType.LockedOut:
return new UserFriendlyException(L("LoginFailed"), L("UserLockedOutMessage"));
default: //Can not fall to default actually. But other result types can be added in the future and we may forget to handle it
Logger.Warn("Unhandled login fail reason: " + result);
return new UserFriendlyException(L("LoginFailed"));
}
}
我看看log.txt文件,發現
WARN 2017-09-27 10:51:55,219 [8] MPA_EF.Web.Controllers.AccountController - 登錄失敗! Abp.UI.UserFriendlyException:登錄失敗! at BBWP_ABP_MPA_EF.Web.Controllers.AccountController.d__13.MoveNext()in C:_Ambienti \ vs2015 \ Biosic \ module-zero-template-2.1.1 \ src \ BBWP_ABP_MPA_EF.Web \ Controllers \ AccountController.cs:line 130 - - 從以前位置拋出異常的位置結束堆棧--- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System。 Runtime.CompilerServices.TaskAwaiter 1.GetResult() at BBWP_ABP_MPA_EF.Web.Controllers.AccountController.<Login>d__12.MoveNext() in C:\_Ambienti\vs2015\Biosic\module-zero-template-2.1.1\src\BBWP_ABP_MPA_EF.Web\Controllers\AccountController.cs:line 100 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult
1.CallEndDelegate(IAsyncResult的asyncResult) 在System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase 1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult
1.CallEndDelegate(IAsyncResult的asyncResult) 在System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1。結束() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker。 <> c__DisplayClass21。 <> c__DisplayClass2b.b__1c() at System.Web.Mvc.Async.AsyncControllerActionInvoker。 <> c__DisplayClass21.b__1e(IAsyncResult的asyncResult)
編輯 在登錄方法
Standard Login method AccountController.cs
Login method inside my project
嗨亞倫, 沒有它裏面的AccountController – Saro
GetLoginResultAsync方法內部控制的登錄方法調用GetLoginResultAsync 反正租戶是該應用程序禁用 – Saro
沒有,一切都是「標準」 – Saro