Exemple #1
0
        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);
        }
Exemple #2
0
        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.");
            }
        }
Exemple #3
0
        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);
        }