Advertisement
rockdrilla

passdb_lookup()

May 9th, 2017
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE FUNCTION passdb_lookup(TEXT)
  2. RETURNS TABLE("user" TEXT, "password" TEXT)
  3. LANGUAGE sql
  4. AS $$
  5.   SELECT
  6.     name, password_digest
  7.   FROM mailboxes
  8.   WHERE (NOT is_alias) AND (active)
  9.     AND ((lower($1) = name) OR (lower($1) = login))
  10.   UNION
  11.   SELECT
  12.     lower($1), password_digest
  13.   FROM mailboxes
  14.   WHERE (active) AND id IN (
  15.     SELECT
  16.       parent_id
  17.     FROM mailboxes
  18.     WHERE (active) AND (is_login_alias)
  19.       AND (lower($1) = name)
  20.   )
  21. $$;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement