public void Register(string username, string password) { SQLiteConn conn = SQLiteConn.Instance; if (conn.QueryUser(username)) { throw new FaultException("Username already exists."); } conn.InsertUser(username, password); }
private void CheckToken(string username, string token) { SQLiteConn conn = SQLiteConn.Instance; if (!conn.QueryUser(username)) { throw new FaultException("Username does not exist."); } string usertoken = conn.GetToken(username); if (usertoken != token) { throw new FaultException("Bad token."); } }
public string LogIn(string username, string password) { SQLiteConn conn = SQLiteConn.Instance; if (!conn.QueryUser(username, password)) { throw new FaultException("Wrong password or username does not exist."); } string token = Guid.NewGuid().ToString(); conn.SetToken(username, token); return(token); }