財產這是我的用戶模型的樣子:MongoDB的C# - 隱藏串行
namespace Api.Models
{
public class User
{
[BsonId(IdGenerator = typeof(StringObjectIdGenerator))]
[BsonRequired]
public string Id { get; set; }
[Required(ErrorMessage = "Username is required.")]
[StringLength(20, MinimumLength=3, ErrorMessage="Username must be between 3 and 20 characters.")]
[BsonRequired]
public string Username { get; set; }
[Required(ErrorMessage="Email is required.")]
[EmailAddress(ErrorMessage="Valid email required.")]
[BsonRequired]
public string Email { get; set; }
[Required(ErrorMessage = "Password is required.")]
[StringLength(50, MinimumLength=8, ErrorMessage="Password must be between 8 and 50 characters.")]
[BsonRequired]
public string Password { get; set; }
[BsonRequired]
public string Salt { get; set; }
}
}
我想寫點什麼,並要求,所有的屬性到的MongoDB數據庫。我不想做的,是揭示密碼和鹽屬性,當我通過請求發送此。
是否有任何一種數據屬性,我可以設置它會寫它,但不顯示任何API用戶時顯示?
你是什麼意思的「暴露」?怎麼樣? –
說通過POST創建一個用戶,然後發回模型給用戶,我想鹽和密碼保存在mongoDB中,但不發送回瀏覽器/用戶 – ehftwelve