Public User Registration #3083
Replies: 24 comments 56 replies
-
We're planning on adding this as a dedicated section in the Project Settings... and I think this would be our field layout... right after the "Public Pages" section:
We can ignore the last 4 fields for MVP (Directus only), and/or add them for supporting white-labeled user management on the client project side. |
Beta Was this translation helpful? Give feedback.
-
Adding close public registration options. Enabled or disabled. |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
I really like this feature request. I imagine using this register endpoint directly on our websites/apps. |
Beta Was this translation helpful? Give feedback.
-
I would like to see this feature too |
Beta Was this translation helpful? Give feedback.
-
Hi. Just want to confirm if this feature, or something like it, has been implemented? I've been going over the docs but don't see it anywhere. Thanks. |
Beta Was this translation helpful? Give feedback.
-
I propose a flag: EMAIL_VERIFICATION
Which when true will send a link which a user has to press or has a code to enter
If false, the verification will be skipped.
Beste Grüße,
Nils Baumgartner
… Am 13.08.2022 um 03:43 schrieb sooqwaifr ***@***.***>:
How do we handle email verification? In case the user enters a wrong email?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
|
Beta Was this translation helpful? Give feedback.
-
I think auth0GitHubopen API |
Beta Was this translation helpful? Give feedback.
-
@rijkvanzanten not quite the same as a user registration but with the user invitation you could do the same as with reset passwords. So you it would be possible to add a custom address as an argument.
Currently trying to find out which fields needs te be public for user invites to work |
Beta Was this translation helpful? Give feedback.
-
Maybe this will help someone looking for a proper user registration workaround (with email confirmation). I have utilized
const jwt = require('jsonwebtoken')
const { Url } = require('directus/utils/url')
module.exports = async function registerHook(
{ filter, action },
{ services, exceptions, env }
) {
const { AuthenticationService, MailService } = services
const { InvalidCredentialsException } = exceptions
filter(
'users.create',
async (input, { collection }, { database, schema, accountability }) => {
// Do not change the payload if request comes from app / admin
if (!accountability || (accountability.admin && accountability.app))
return
delete input.status
delete input.role
return input
}
)
action('users.create', async ({ payload }, { schema, accountability }) => {
// Do not send activation email if user is created from app or by admin
if (!accountability || (accountability.admin && accountability.app))
return
const mailService = new MailService({
accountability,
schema
})
const { email } = payload
const tokenPayload = { email, scope: 'invite' }
const token = jwt.sign(tokenPayload, env.SECRET, {
expiresIn: '7d',
issuer: 'directus'
})
const inviteURL = new Url(env.FRONTEND_URL).addPath('user-confirm')
inviteURL.setQuery('token', token)
await mailService.send({
to: email,
subject: 'Confirm your user account',
template: {
name: 'user-invitation',
data: {
url: inviteURL.toString(),
email
}
}
})
})
} For verification, I have created a simple new POST endpoint const jwt = require('jsonwebtoken')
module.exports = (router, { services, exceptions, database, env }) => {
const { UsersService } = services
const {
InvalidPayloadException,
ForbiddenException,
ServiceUnavailableException
} = exceptions
router.post('/activate', async (req, res, next) => {
try {
const { token } = req.body
const { email, scope } = jwt.verify(token, env.SECRET, {
issuer: 'directus'
})
if (scope !== 'invite')
return next(
new ForbiddenException(
`You are not allowed to perform this operation.`
)
)
// Find user in DB by email
const user = await database
.select('id', 'status')
.from('directus_users')
.where({ email })
.first()
// Check user status - must be "invited"
if (user?.status !== 'invited') {
return next(
new InvalidPayloadException(
`Email address ${email} hasn't been invited.`
)
)
}
const usersService = new UsersService({ schema: req.schema })
await usersService.updateOne(user.id, { status: 'active' })
res.send('OK')
} catch (error) {
return next(new ServiceUnavailableException(error.message))
}
})
} I've taken most of the logic from |
Beta Was this translation helpful? Give feedback.
-
Would be nice to make a own extension/ npm package of this |
Beta Was this translation helpful? Give feedback.
-
Will an e-mail validation be part of this? I personally think this is one of the most important missing parts. directus/api/src/services/users.ts Lines 360 to 405 in 57b0234 Will probably start an integration with the beginning of the year. |
Beta Was this translation helpful? Give feedback.
-
O, Im created similar theme, maybe somebody help me find a resolve? #16977 |
Beta Was this translation helpful? Give feedback.
-
I'm curious – this has been in the short term section of directus' roadmap for a while now. Is it something we will see in the coming months? I'm really excited for this! |
Beta Was this translation helpful? Give feedback.
-
So this solutions seems for me better. It also is very similar to GitLab implementation?
|
Beta Was this translation helpful? Give feedback.
-
Is there any way to display a form for the public / not logged in user? I tried creating an intermediary table - "signup" with public write access. Is there some way to display that form without logging in? |
Beta Was this translation helpful? Give feedback.
-
Heya! Thanks for opening this feature request! This feature request has received over 15 votes from the community. This means we'll move this feature request to the Under Review state! The Core team will schedule a meeting to review this request as soon as possible. The discussion will then be approved or denied. You may or may not be invited to join this meeting with the core team. For more information, see our Feature Request Process. |
Beta Was this translation helpful? Give feedback.
-
How to determine role with public registration?
|
Beta Was this translation helpful? Give feedback.
-
settings => access control => Public => system collection => directus_user => create => use custom => field permissions(forbid role field) => field presets( set {role : "your system normal role"} ) then enjoy sign up |
Beta Was this translation helpful? Give feedback.
-
/users Now visitors have permission to this |
Beta Was this translation helpful? Give feedback.
-
@rijkvanzanten looks like this was released on version 10.11.0. Can it be marked as resolved? 🤔 |
Beta Was this translation helpful? Give feedback.
-
Being able to register as a new user. Couple questions to discuss:
POST /users
? Dedicated/users/register
?)Beta Was this translation helpful? Give feedback.
All reactions