Temporary users that require no email address

hello everyone,

I have a potential project for a museum that needs some specific user manangement and I am not so sure on how to accomplish this.

use case
groups of children and a teacher will recieve a user so they can together create a page and some subpages, upload images, etc. for this I would create a frontend login area and this user type will not have panel access.

the museum employees will have a few regular panel accounts that can create the users I mentioned above. after they create a user they can send the login info to the teacher so they can work on their stuff.

since it is a group, one of the requirements is that these frontend users don’t use email addresses but rather usernames. sure, the teacher could use her/his email or something, but that is the description of what they want.

my test
I was testing a simple workflow today: I created a new type of user and the simple frontend login with help from the cookbook recipes and all works great.

the issue is though that I am using email addresses. when an admin creates a new frontend user in the panel, the email field is a requirement. again, here I could tell the client, you can use your domain, like @client.com and just give them some ID as an address, like 1839iop@client.com. but it seems like a counterintuitive thing to do for an institution to use random email addresses that each employee would have to choose.

also, for loging in in the frontend, the email and password are checked and it would have to be username and password instead.

is there a cleaner solution for this? optimally it would look like:

  • museum employee starts new frontend user creation in the panel
  • in the modal that opens the email is not asked nor required, but rather an automatic generated ID that is unique is already prefilled (meaning it would have to check if the ID already exists, or maybe just generate it from a timestamp or something)
  • in the frontend the teacher logs in with the username and password

that way no email address is stored nor needed for the school group.

bonus question
also, the frontend accounts must have a time to live. so the museum employee would create the user and give it 10 days or soemthing. after that, the login should not work anymore. I havent looked into this yet but maybe someone has a nice clean suggestion as well :slight_smile: my first idea was something like an automatic change of roles from frontenduser to frontenduserdisabled that happens after the time has elapsed. that way the employees can quickly see in the panel which users are already inactive. what would you suggest?

thank you all in advance!

You can create a user model: User models | Kirby CMS

In that model you can overwrite the relevant methods (login etc.)

dear sonja,

thank you, thats helpful indeed. I am not that savvy with this kind of complexity though, that kinda touches the core of kirby. if i understand correctly the user model would allow me to login somehow without the email address, correct? but would it also change this modal in the panel where entering an email address is mandatory? does this modal practically feed from each user model’s role and if I change the methods of the user role the modal would adjust itself as well?

I checked your link and I kinda understand the principle of your suggestion but I have no idea on how I would even start :see_no_evil: can you please hint me in the right direction?

No, the form would not adapt automatically, didn’t think of that. Maybe it could be achieved with overwriting the dialog. But I’ve never tried something like that.

oh ok. I will play around with the user models in the next days and see if I can at least login with only username and password. maybe in the meantime someone has an idea on how to adjust the user form when creating a new user. thank you!

so I have an update on this. I ended up creating a new panel area to solve my issues. it was super unclean since i copy pasted a lot of things, but it is working. I found an aswer of yours sonja to another question here in the forum regarding how to login without email and you suggest using a form with username and passwor, fetching the email address of the user by using the username, and then login in with the fetched email and the password that was entered. to avoid double user names I made my plugin area so, that the email is generated by the system, and the admin user can enter a username, but the username also gets the same ID as the generated email, for instance:

generated email:
938i827@client.com

name the admin gives the new frontenduser:
someschool

username that gets saved:
someschool_938i827

Bildschirmfoto 2022-08-11 um 14.26.47

with that the admins dont have to worry about creating random emails and i dont have to worry that there will be identical usernames. right now the admins can still change the emails and usernames afterwards, but i think it is a good start.

for my custom panel area i pretty much copy pasted the regular user panel area and adjusted the vue components and php codes etc. one last issue i am having is, that in my TempUsers.vue (at least i think it is here) the k-collection gets auto generated and the URLs are still using the /users path and not my new /temporaryusers path

<template v-if="users.data.length > 0">
				<k-collection
					:items="items"
					:pagination="users.pagination"
					@paginate="paginate"
				/>
</template>
<template v-else-if="users.pagination.total === 0">
				<k-empty icon="users">
					{{ $t("role.empty") }}
				</k-empty>
</template>

here is what i mean

so if i click on the user to edit it, i get redirected to /users/userid

do you have any suggestions? do you think going with an extra panel area is the way to go or should i better try something else?