- Sun Jul 05, 2015 9:53 pm
#890
I created my project as a MPA site, then added in Zero following the instructions here: http://www.aspnetboilerplate.com/Pages/ ... stallation
Ran all appropriate migrations and seed methods.
I then created an AngularJS admin app. I created a UserAppService with GetUsers() and tested in the console like demoed here: http://www.aspnetzero.com/Documents/Dev ... er-console
This is where I first got the error for MustHaveTenant. So I assumed it was because I wasn't logging in. I went to the login form and on the LoginAsync method, I get the "Filter name MustHaveTenant not Found" exception when the method _userManager.LoginAsync() runs and trying to login as 'admin' / '123qwe'.
I've read every document 10x now and cannot figure out why this happening.
Ran all appropriate migrations and seed methods.
I then created an AngularJS admin app. I created a UserAppService with GetUsers() and tested in the console like demoed here: http://www.aspnetzero.com/Documents/Dev ... er-console
This is where I first got the error for MustHaveTenant. So I assumed it was because I wasn't logging in. I went to the login form and on the LoginAsync method, I get the "Filter name MustHaveTenant not Found" exception when the method _userManager.LoginAsync() runs and trying to login as 'admin' / '123qwe'.
I've read every document 10x now and cannot figure out why this happening.
Code: Select all
[HttpPost]
public async Task<JsonResult> Login(LoginViewModel loginModel, string returnUrl = "")
{
if (!ModelState.IsValid)
{
throw new UserFriendlyException("Your form is invalid!");
}
var loginResult = await _userManager.LoginAsync(
loginModel.UsernameOrEmailAddress,
loginModel.Password,
loginModel.TenancyName
);
switch (loginResult.Result)
{
case AbpLoginResultType.Success:
break;
case AbpLoginResultType.InvalidUserNameOrEmailAddress:
case AbpLoginResultType.InvalidPassword:
throw new UserFriendlyException("Invalid user name or password!");
case AbpLoginResultType.InvalidTenancyName:
throw new UserFriendlyException("No tenant with name: " + loginModel.TenancyName);
case AbpLoginResultType.TenantIsNotActive:
throw new UserFriendlyException("Tenant is not active: " + loginModel.TenancyName);
case AbpLoginResultType.UserIsNotActive:
throw new UserFriendlyException("User is not active: " + loginModel.UsernameOrEmailAddress);
case AbpLoginResultType.UserEmailIsNotConfirmed:
throw new UserFriendlyException("Your email address is not confirmed!");
default: //Can not fall to default for now. But other result types can be added in the future and we may forget to handle it
throw new UserFriendlyException("Unknown problem with login: " + loginResult.Result);
}
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = loginModel.RememberMe }, loginResult.Identity);
if (string.IsNullOrWhiteSpace(returnUrl))
{
returnUrl = Request.ApplicationPath;
}
return Json(new MvcAjaxResponse { TargetUrl = returnUrl });
}