-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow users to fill out forms as GUEST and send email responses #870
Conversation
@@ -67,21 +73,22 @@ open class FormService( | |||
if (form.availableUntil < now) | |||
return FormView(status = FormStatus.TOO_LATE) | |||
|
|||
if (form.allowedGroups.isNotBlank() && userRepository.findById(user.id) | |||
if (user?.id != null && form.allowedGroups.isNotBlank() && userRepository.findById(user.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably works this way too, but I would probably only check on the user, not the id of it.
} else { | ||
responseRepository.findByFormIdAndSubmitterUserId(form.id, user.id).orElse(null) | ||
user?.id?.let { responseRepository.findByFormIdAndSubmitterUserId(form.id, it).getOrNull() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, this probably works just fine, but I don't think we need to check both the user and the id of the user.
By the way, will the submissionEntity default to null if the user is null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing null to an SQL query has a very different meaning than skipping the query if the parameter is null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
One issue I see is that the A few ideas on how this could be handled:
|
val form = formRepository.findAllByUrl(path).getOrNull(0) | ||
?: return FormView(status = FormStatus.NOT_FOUND) | ||
|
||
if ((form.minRole.value > user.role.value || form.maxRole.value < user.role.value) && !user.role.isAdmin) | ||
val role = user?.role ?: RoleType.GUEST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an idea:
We could have an UnauthenticatedUser : CmschUser
instead of null
for representing unauthenticated users, and then these null-checks wouldn't be needed. This would require making most of the attributes on CmschUser
nullable, so might not be worth it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it. I think it would improve the codebase. But it would be a part of a major, bigger scope refactor in my opinion
} | ||
|
||
|
||
private fun getEmailForConfirmation( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private fun getEmailForConfirmation( | |
private fun getEmailAddressForConfirmation( |
…lling out templates
bd3a594
to
3df4629
Compare
closes #859