]> SAFE projects GIT repository - jmp/mailleur/commitdiff
experience with trigger
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Mon, 7 Jul 2025 19:42:35 +0000 (15:42 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Mon, 7 Jul 2025 19:42:35 +0000 (15:42 -0400)
sql/mailleur.sql

index 927868dd9718bc9f0a7ec5690a586afbccb3302b..275c6d99f60264025aeeac5947ed6540a00418f4 100644 (file)
@@ -55,10 +55,11 @@ CREATE TABLE emails (
        email           TEXTUNIQUE,     //User email
        password        TEXT            //User password
                        DFLT '!',
-       realm           TEXT            //user realm
-                       DFLT 'MAILLEUR-EMAIL',
-       hash            TEXT            //'email:realm:passwor' MD5
+       realm           TEXT            //'email:realm:password' MD5
                        DFLT '0ABCD9',
+       seq             BIGINT          //HASH as a seq
+                       DFLT 0,
+       hash            TEXT,           //'email:realm:passwor' MD5
        space           INTEGER         //space used by user email      
                        DFLT 0,
        mxspace         INTEGER         //Maximun space available
@@ -74,6 +75,7 @@ GRANT SELECT                          ON emails TO maildove;
 CREATE FUNCTION updpass()
   RETURNS trigger AS $$
        BEGIN
+       NEW.seq = hashtextextended(md5(concat (NEW.email,':',NEW.realm,':',new.password)),0);
        NEW.hash = md5(concat (NEW.email,':',NEW.realm,':',new.password));
        NEW.password = crypt(new.password, gen_salt('md5'));
        RETURN NEW;