我想使用我创建的登录api在nopcommerce中使用查询字符串登录。我想用查询字符串点击我的方法并重定向到用户仪表板。我创建简单的登录方法,在里面,我使用nopcommerce用于登录的确切代码。在使用查询字符串并按Enter后,api的登录方法获得了所有行成功执行但它没有重定向到登录的用户仪表板。重定向同一页面而不登录。这是我的代码
[HttpGet]
public ActionResult Login(string username, string password)
{
var loginResult =_customerRegistrationService.ValidateCustomer(username,password);
//
switch (loginResult)
{
case CustomerLoginResults.Successful://get in here.
{
var customer = _customerSettings.UsernamesEnabled ? _customerService.GetCustomerByUsername(username) : _customerService.GetCustomerByEmail(username);
//migrate shopping cart
_shoppingCartService.MigrateShoppingCart(_workContext.CurrentCustomer, customer, true);
//sign in new customer
_authenticationService.SignIn(customer,false);
//raise event
_eventPublisher.Publish(new CustomerLoggedinEvent(customer));
//activity log
_customerActivityService.InsertActivity("PublicStore.Login", _localizationService.GetResource("ActivityLog.PublicStore.Login"), customer);
//if (String.IsNullOrEmpty(returnUrl) || !Url.IsLocalUrl(returnUrl))
return RedirectToRoute("HomePage");
//return Redirect(returnUrl);
}
case CustomerLoginResults.CustomerNotExist:
ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials.CustomerNotExist"));
break;
case CustomerLoginResults.Deleted:
ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials.Deleted"));
break;
case CustomerLoginResults.NotActive:
ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials.NotActive"));
break;
case CustomerLoginResults.NotRegistered:
ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials.NotRegistered"));
break;
case CustomerLoginResults.WrongPassword:
default:
ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials"));
break;
}
if (loginResult.ToString()=="Successful")
{
return Successful(loginResult);
}
else
{
return ErrorOccured("Wrong Credentials");
}
}