Commit 781d42b4e53b43e2392abd5d851b2ff2a38353a4

Authored by Antonio Terceiro
1 parent dbc3b318

ActionItem1165: changing the mail view definition

Showing 1 changed file with 16 additions and 6 deletions   Show diff stats
util/mail/postgresql/mail_users.sql
@@ -2,7 +2,7 @@ CREATE OR REPLACE VIEW mail_users @@ -2,7 +2,7 @@ CREATE OR REPLACE VIEW mail_users
2 AS 2 AS
3 SELECT 3 SELECT
4 users.login || '@' || domains.name as username, 4 users.login || '@' || domains.name as username,
5 - '{MD5}' || encode(decode(users.crypted_password,'hex'), 'base64') 5 + users.crypted_password as crypted_password,
6 as passwd, 6 as passwd,
7 '' as clearpasswd, 7 '' as clearpasswd,
8 5000 as uid, 8 5000 as uid,
@@ -20,10 +20,21 @@ JOIN profiles on @@ -20,10 +20,21 @@ JOIN profiles on
20 JOIN environments on 20 JOIN environments on
21 (environments.id = profiles.environment_id) 21 (environments.id = profiles.environment_id)
22 JOIN domains on 22 JOIN domains on
23 - (domains.owner_id = environments.id and  
24 - domains.owner_type = 'Environment') 23 + (
  24 + (
  25 + profiles.preferred_domain is null and
  26 + domains.owner_id = environments.id and
  27 + domains.owner_type = 'Environment'
  28 + )
  29 + OR
  30 + (
  31 + profiles.preferred_domain_id is not null and
  32 + domain.owner_id = profiles.id and
  33 + domains.owner_type = 'Profile'
  34 + )
  35 + )
25 WHERE 36 WHERE
26 - users.password_type = 'md5' 37 + users.password_type = 'crypt'
27 AND domains.is_default 38 AND domains.is_default
28 AND users.enable_email; 39 AND users.enable_email;
29 40
@@ -47,5 +58,4 @@ JOIN domains domains_to on @@ -47,5 +58,4 @@ JOIN domains domains_to on
47 domains_to.owner_type = 'Environment' and 58 domains_to.owner_type = 'Environment' and
48 domains_to.is_default) 59 domains_to.is_default)
49 WHERE 60 WHERE
50 - users.password_type = 'md5'  
51 - AND users.enable_email; 61 + users.enable_email;