Exemple #1
0
 /// <summary>
 /// Login the current user
 /// </summary>
 /// <param name="username"></param>
 /// <param name="password"></param>
 /// <returns>Returns the number of rows</returns>
 public int Login(string username, string password)
 {
     password = SHAEncrypt.GenerateSHA512String(password);
     using (db = Database.Open("aSpecialDay"))
     {
         int loggedIn = db.QueryValue("SELECT COUNT(*) FROM Login WHERE Username = @0 AND Password = @1", username, password);
         return(loggedIn);
     }
 }
Exemple #2
0
    /// <summary>
    /// Register a new user to the website
    /// </summary>
    /// <param name="username"></param>
    /// <param name="password"></param>
    /// <returns></returns>
    public int Register(string username, string password)
    {
        password = SHAEncrypt.GenerateSHA512String(password);
        using (db = Database.Open("aSpecialDay"))
        {
            int insert = db.Execute("INSERT INTO Login (Username, Password) " +
                                    "SELECT @0, @1 " +
                                    "WHERE NOT EXISTS(SELECT Username FROM Login WHERE Username = @0)", username, password);

            return(insert);
        }
    }