Set default group for signups #1662
-
What would be the best way to automatically put people in a certain group? I want to restrict write access to docs, so I've added permissions to all collections for an Any ideas would be highly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
This is a good idea, the ability to set one or more "default" groups – but it's not something that exists right now. If there is interest in adding this feature I could write up some guidance on how best to implement… |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply! For the meantime, do you recon this would work? I'm no SQL expert and especially not PostgreSQL so would appreciate a second opinion :) CREATE OR REPLACE FUNCTION add_new_user_to_group()
RETURNS trigger AS
$$
BEGIN
INSERT INTO group_users
("userId",
"groupId",
"createdById",
"createdAt",
"updatedAt",
"deletedAt")
VALUES
(NEW.id,
(SELECT id from groups where name='readers'),
(SELECT id from users where "isAdmin"='true'),
NOW(),
NOW(),
null);
RETURN NEW;
END
$$
LANGUAGE plpgsql;
CREATE TRIGGER after_user_insert
AFTER INSERT ON users
FOR EACH ROW
EXECUTE FUNCTION add_new_user_to_group(); |
Beta Was this translation helpful? Give feedback.
-
This could be a feature in Outline. In Settings, you can put users into a default group, what u think tom? |
Beta Was this translation helpful? Give feedback.
Thanks for your reply!
For the meantime, do you recon this would work? I'm no SQL expert and especially not PostgreSQL so would appreciate a second opinion :)