summaryrefslogtreecommitdiff
path: root/sql/functions/auth.get_active_user_by_id.sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql/functions/auth.get_active_user_by_id.sql')
-rw-r--r--sql/functions/auth.get_active_user_by_id.sql27
1 files changed, 27 insertions, 0 deletions
diff --git a/sql/functions/auth.get_active_user_by_id.sql b/sql/functions/auth.get_active_user_by_id.sql
new file mode 100644
index 0000000..7f635a0
--- /dev/null
+++ b/sql/functions/auth.get_active_user_by_id.sql
@@ -0,0 +1,27 @@
+drop function auth.get_active_user_by_id (
+ p_user_id bigint
+);
+
+create or replace function auth.get_active_user_by_id (
+ p_user_id bigint
+)
+returns setof auth.users
+as $$
+begin
+ return query
+ select u.id,
+ u.username,
+ u.pwd,
+ u.first_name,
+ u.last_name,
+ u.email,
+ u.phone,
+ u.active,
+ u.created
+ from auth.users u
+ where u.id = p_user_id
+ and u.active = true;
+
+ return;
+end;
+$$ language plpgsql;