我有一个用户名和密码但是为了测试我已经硬编码了数据库中的用户名和密码。
密码在数据库中加密
但显然如果我这样做:
public ActionResult LoginBalieUser(LoginModel model)
{
var salesAgent = CommerceFramework.ShopAccounts.GetShopAccount(Guid.Parse("3E90BB13-36BA-435D-8ED7-E930A4F8C758"), true);
model.Password = "EielKrkK4Gh5T95aUfY149YtbaFXEia7dAjTP0IyWaY=";
if (model.UserName == "info@verploegen.nl")
{
if (model.UserName == "info@verploegen.nl" && model.Password == "EielKrkK4Gh5T95aUfY149YtbaFXEia7dAjTP0IyWaY=")
{
if (!ModelState.IsValid)
return View(model);
}
if (!ShopApi.UserState.Login(model.UserName, model.Password, model.RememberMe))
{
ModelState.AddModelError("", "");
return View(model);
}
}
return RedirectToAction("Login", "Profile");
}
我看着
if (!ModelState.IsValid)
密码始终为空。但这是密码的正确字符串。
因为这是将在DB中保存的xml:
<FieldsDictionary>
<field name="Password" type="System.String, mscorlib">
<string>EielKrkK4Gh5T95aUfY149YtbaFXEia7dAjTP0IyWaY=</string>
</field>
<field name="Salt" type="System.String, mscorlib">
<string>vn73BOyHEIzE/SxFxYrCSA==</string>
</field>
<field name="AccountDisplayName" type="Null" />
<field name="CanOrderProducts" type="System.Boolean, mscorlib">
<boolean>true</boolean>
</field>
<field name="CanSeePrices" type="System.Boolean, mscorlib">
<boolean>true</boolean>
</field>
<field name="CanSeeStock" type="System.Boolean, mscorlib">
<boolean>true</boolean>
</field>
<field name="HasLimitedBudget" type="System.Boolean, mscorlib">
<boolean>false</boolean>
</field>
</FieldsDictionary>
那么如何获取密码?
谢谢
这是模型:
//
// Summary:
// A model to login into the webshop.
public class LoginModel
{
public LoginModel();
//
// Summary:
// Gets or sets the password.
[AllowHtml]
[DataType(DataType.Password)]
[Display(Name = "Password")]
[Required(ErrorMessageResourceName = "Validation_RequiredField")]
[StringLength(30, ErrorMessageResourceName = "Validation_MaxLengthExceeded")]
public virtual System.String Password { get; set; }
//
// Summary:
// Gets or sets a value indicating whether to remember the user to login him automatically
// on the next visit.
[Display(Name = "Login_RememberMe")]
public virtual System.Boolean RememberMe { get; set; }
//
// Summary:
// Gets or sets the username.
[DataType(DataType.EmailAddress, ErrorMessageResourceName = "Validation_InvalidField")]
[Display(Name = "EmailAddress")]
[Required(ErrorMessageResourceName = "Validation_RequiredField")]
[StringLength(80, ErrorMessageResourceName = "Validation_MaxLengthExceeded")]
[TrimAttribute(new[] { })]
public virtual System.String UserName { get; set; }
}
这是观点:
@{
Layout = LayoutPaths.General;
}
@*@model Sana.Commerce.DomainModel.Account.V_LoginModel_BalieUser*@
@model LoginModel
<div class="semicolumn">
<div class="form-holder">
@using (Html.BeginForm(htmlAttributes: new { @class = "form" }))
{
@Html.AntiForgeryToken()
<table>
<tr>
<th>
@Html.DisplayNameFor(modelItem => modelItem.UserName)
</th>
<th></th>
</tr>
<tr>
<td>
@Html.TextBoxFor(modelItem => modelItem.UserName)
</td>
</tr>
</table>
<div class="form-row">
<h4></h4>
<input type="submit" value="Login" />
</div>
}
</div>
<div>
</div>
</div>
所以我有一个文本字段,我在其中填写用户名info@verploegen.nl
,但我在操作方法中设置了硬编码密码,以便您可以看到。