![](/img/trans.png)
[英]How can I validate if a user has written in the same two passwords correctly in my view?
[英]How can I check if a user has written his username and password correctly?
我正在使用一個名為Scans.dbml的Linq-to-SQL類。
在該類中,我將一個名為Users(用戶名,密碼,角色)的表拖到了圖形區域上,現在可以通過UserRepository類訪問User對象:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Scanner.Classes
{
public class UserRepository
{
private ScansDataContext db = new ScansDataContext();
public User getUser(string username)
{
return db.Users.SingleOrDefault(x => x.username == username);
}
public bool exists(string username)
{
}
}
}
現在,在“登錄”表單中,我想使用Linq-to-SQL的優點來進行所有與數據相關的活動。
UserRepository users = new UserRepository();
private void btnLogin_Click(object sender, EventArgs e)
{
loginToSystem();
}
private void loginToSystem()
{
if (users.getUser(txtUsername.Text))
{
}
//If txtUsername exists && User.password == Salt(txtPassword)
//then Show.MainForm() with User.accountType in constructor to set permissions.
}
有什么指導嗎?
通常:散列任何用戶類型,並將其與存儲的散列進行比較。
但是,如果這是一個asp.net項目,則建議使用'SqlMembershipProvider'。 它可能會提供您需要的所有功能,而您無需重新發明輪子。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.