automated user registration
-
Hi,
We have a lot of users and don't always know who needs access to our cloudron setup. Is there a way to automate user registration or that registration is open, but for instance moderated?
A setup that would work well for us:
- user registers their account on cloudron
- (optionally, but nice) if their email isn't in the whitelist, continue, else decline registration
- add to moderation queue
- moderator approves or declines, this could even be that the user already exists but needs adding to groups.
If that isn't possible, which would be sad, being able to mass invite a list of e-mail addresses or sent a single invite link to a mailinglist would also work.
Setting the registration deadline would also be quite helpful here, very few people respond to their invite within a day.
Thanks!
-
@fair Currently, there is no way to have self-registration. I guess this request is similar to https://forum.cloudron.io/topic/2068/is-it-possible-to-have-open-registation . You can use the API to implement bulk invites - https://cloudron.io/documentation/api/#/paths/~1users/post . Would that work?
-
@girish said in automated user registration:
I guess this request is similar to https://forum.cloudron.io/topic/2068/is-it-possible-to-have-open-registation
You beat me to it
Perhaps move that and this thread to feature requests?
-
@jdaviescoates Done!
@fair For now, I can write a script and publish it here. Let's take it from there.
-
@fair said in automated user registration:
if their email isn't in the whitelist, continue, else decline registration
for "isn't" read "is" (?)
-
@jdaviescoates This looks quite interesting, I'm currently trying to make a script that will make users. But I think I'm missing bits and/or the docs are out of date. I manage to login, but get these fields back:
- accessToken
- tokenScopes
- identifier
- clientId
- expires
What I'm missing is what to do with those fields. Having them as cookies doesn't seem to work
-
Got authentication working, requesting status works, but when I want to get a list of users with /api/v1/users
I get:
{
"status": "Unauthorized",
"message": "Unauthorized"
}I also get this when trying to use this from the browser, but this is using the admin user.
-
@fair The status call doesn't require auth which is why maybe you think it work (but it doesn't). I tried quickly, this is how it should work:
$ curl https://my.demo.cloudron.io/api/v1/users?access_token=0c65ac11c01b894f29ae24e47023982b2e81413f45324af8b5be22cc65a4c61d { "users": [ { "id": "uid-519b3541-7f42-4132-b1fc-225361b7c4a7", "username": "ahoruz", "email": "removed", "displayName": "Ali", "active": true }, { "id": "uid-d9e1bd2b-1214-4fec-9cac-d6cdeaf62bcd", "username": "cloudron", "email": "admin@cloudron.io", "displayName": "cloudron", "active": true } ] }
-
@fair Here's a script to create a user and invite them.
#!/bin/bash set -eu # fill these in cloudron=my.domain.com token=a803859d40c9ec4e111ccb111111111111111111111 # the user to add and invite username=test email=test@cloudron.io displayName="Test User" function urlencode() { # https://unix.stackexchange.com/questions/159253/decoding-url-encoding-percent-encoding python2.7 -c "import sys, urllib as ul; print(ul.quote_plus(sys.argv[1]))" $1 } # add user if ! out=$(curl -sS --fail -H 'Content-Type: application/json' -X POST -d "{ \"email\": \"${email}\", \"username\": \"${username}\", \"displayName\": \"${displayName}\" }" https://${cloudron}/api/v1/users?access_token=${token}); then echo "Failed to add user" exit 1 fi userid=$(echo ${out} | jq -r .id) echo "User added: ${userid}" # create an invite. this does not send the email. if you like you can share the invite link using other channels if ! out=$(curl -sS --fail -H 'Content-Type: application/json' -X POST https://${cloudron}/api/v1/users/${userid}/create_invite?access_token=${token}); then echo "Failed to create invitation" exit 1 fi resetToken=$(echo ${out} | jq -r .resetToken) encodedEmail=$(urlencode "${email}") encodedDisplayName=$(urlencode "${displayName}") echo "reset token: ${resetToken} . URL for user to sign up: https://${cloudron}/setupaccount.html?resetToken=${resetToken}&email=${encodedEmail}&displayName=${encodedDisplayName}&username=${username}&profileLocked=true" # tell cloudron to send the invite by mail. invite links are only valid for a day from when they were created if ! out=$(curl -sS --fail -H 'Content-Type: application/json' -X POST https://${cloudron}/api/v1/users/${userid}/send_invite?access_token=${token}); then echo "Failed to send invitation" exit 1 fi echo "Invitation sent"
-
-
-