I am creating a website where you can create an account with your name and email. When this is done, you get a 30 day trial. From this point, you can 'upgrade' your account by supplying more information.
When you do not update your information after 30 days, your account is suspended.
Can anyone give me some tips how to do this ?
So:
- Create profile with email and name (easy), indicator is stored in db that you are trial user.
- When you log in, you can extend your profile with extra information. indicator that you are full user.
You can always write your own module to do it, but my recommendation is using the Rules module, and using several user roles.
Any new user gets a "trial" role he registers.
Create the needed fields in the user profile
Create a rule which will change the user's role in case the field is filled (rule triggeres whenever user profile is updated).
Create a rule with cron that executes once a day, to suspend user account, and probably to send him a notification before doing so.
Related
thanks in advance for any help. I've seen variations of this question, but mine offers a little twist.
I am working on an 'invite only' site (the twist), where administrators create the accounts for the users. I have a form that has the necessary sign in information as well as other user data. Here's where I'm getting tripped up: Some user data goes to Cognito and some goes into DynamoDB but I can't seem to figure out how to associate the two.
To make my example easy (I hope), pretend that the admin form has First Name, Last Name, Email, and User Type. Now first name, last name, and email belong in Cognito, but the UserType belongs on a User table in DynamoDB. I can call Auth.sign_up and it creates the account in Cognito and sends the email to the new user and I can then separately write the user type to a user table in Dynamo DB but something needs to happen to let me know that the user in DynamoDB is the user in Cognito and I don't have all the necessary ids yet.
I've seen using triggers for this, and that could work if I didn't have other custom fields. I could just set up a Post Sign Up trigger and use Lambda to write the new user from Cognito into DynamoDB with the basic name/email. What about the other custom fields such as UserType. It all needs to go through and be associated to the Cognito id in my DynamoDB table. That way when the user logs in, I can pull this data entered in by the admin from DynamoDB.
FWIW, UserType is much more functional to the application and can be changed which is why I feel it belongs in DynamoDB. It's not just "admin" or "normal user" -- it's more specific to the workflows I'm generating.
I may be overthinking this, but I can't work out what the workflow would be to make this work.
Thanks
I am developing an app for my college and there are different types of users called students ,teachers , hod's
etc. When they login, how do I know a teacher logged in, or a student logged in? Is there any function in firestore for role based signups and signins?
I was thinking that when a teacher signs up, I will add a tag end of her uid.username that if username is 'DANIEL' while signup, I will add a tea for teachers and stu for students at the end of the name what they provided.
So when they login i will get the uid and do the string manupulations and get the last three letters so that i can know who logged in so that i can show different UI to Different types of users
Is there any best way to do like this ?
while singning up user enters his username example:"daniel"
i will update that username in uid.username like this "daniel-stu"(if student signed up),"daniel-tea" if techer signsup.
Storing this information in the user's display name can work. You can read it back from there next time, and take action in your application's client-side code. But note that this means that any user can change their role, since they can also call the same code to update their profile. If that is not a concern for your app, then this approach sounds like it would work.
If malicious users should not be able to change their role, then you shouldn't set that role from the client-side application code. In that case, you can set the role from a server (or your development machine, or Cloud Functions) using the Admin SDK. Since the Admin SDK runs in a trusted environment, it has expanded privileges and can update the profile of any user. So the Admin SDK could update the display name of the user in the same way you have in mind.
But this still isn't secure, since you're still setting a property that anyone can modify for their own profile. Again... if that is no problem for your app that is fine, but if the use-case requires that you can rely on the property to be correct, we have to keep looking elsewhere.
The Admin SDK can set additional so-called claims on a user profile that client-side code can't modify. Such claims are for things that affect the permissions of the user, such if the user is an admin, or what role/group your users belong to. This sounds quite close to what you are describing, so can also be used. And this time, only your code that runs in a trusted environment will be able to do so.
Finally, you could store the additional information about a user in the database. It's quite common to have a collection (Users or Profiles) in the database, where you store a document for each user (with the document name being User.uid). You create the document when the user first signs in, and update whenever you need to. You can do this from the client-side code (if there is no need to control what gets written), or from code that runs in a trusted environment (such as your development machine, a server you control, or Cloud Functions) if you do need to keep control. A big advantage of this approach is that all users can potentially see the information in this collection, where the client-side Authentication SDK only allows a user to read their own user profile.
For more on this, see:
Adding new data to firebase users (in which I essentially list the same options with fewer words)
Add extra User Information with firebase (store the information in the realtime database)
Associate Firebase Users to Database Records (also using the realtime database for the additional information)
Cloud Firestore saving additional user data
this video explaining custom claims
and many more previous questions on this topic
So I'm making this app for pharmacists and their patients. Pharmacists can manage their patient's data through the app - and most importantly sign up their patients to the app.
The ideal flow goes like this - at an appointment, pharmacist gets patient's email address. Pharmacists can then create a user account, either setting a password right then for the patient, or sending an email letting the user set one up.
Is there anyway for one user to create an account for another user within firebase?
Cheers
As long as its at a manageable rate as you could hit quota limitations.
The pharmacist can create a new password account with the email provided and some random password and then trigger the reset password flow. This will send a reset password link to the user.
You can then build a custom landing page for resetting the password where the user would take control and finish setting up their account.
Check the docs on building custom email action landing pages:
https://firebase.google.com/docs/auth/custom-email-handler
Im developing a drupal website with multistep approval of users ,after
registration the admin rejects a user an email is sent to the user and the user
is deleted from drupal user table .
I want to perform a action where in after a user is rejected he will be kept in
a new table with the username and email .
If the same user contacts admin,the admin will remove the user from the rejected
users list ,because during registration for second time it should also check for
the user in the rejected user list.
Is i t something that is possible in Drupal?
Any pointers?
Everything is possible except the wooden stove! Show some effort, try something on your own and when you get stuck ask.
There's no out of box solution for this (that I know about it), but what I would do is make custom content type for storing users and use hook functions to insert/check existence of rejected users.
hook that is called when user is deleted:
https://api.drupal.org/api/drupal/modules%21user%21user.api.php/function/hook_user_delete/7.x
hook that is called when node (rejected user) is deleted
https://api.drupal.org/api/drupal/modules!node!node.api.php/function/hook_node_delete/7.x
But maybe your admin can just disable user instead of deleting it as first step - that way wouldn't need that extra table at all.
I looked around for this issue and have found two approaches: use a database table to log users logging in and remove the entry when they log out or session ends; or use Membership.GetNumberOfUsersOnline(). I tried Membership version first but when I log in it shows the number to be zero (I am using form-based authentication, using AD in in Intranet web application and using Oracle DB).
I also created a table having user's ID (what is stored as aspnet_user's username), their aspnet_user's userid, login time stamp and logout time stamp. When user logs in, I add an entry and when users logs out, I remove the entry. The problem here is if session ends and Session_End() event is called I have no way of accessing user's ID (stored in session var) in order to remove the correct entry from table.
In membership, it records certain dates when you login and create activity that update the membership user, and I think the default behavior is to use that... if you are using a custom membership provider, make sure that default behavior is preserved.
Alternatively, if you want to roll your own, to determine number of users online, everytime the user takes an action that posts back, update the time on the user record, and then create a query that checks within a relative amount of time. Session_ENd is not a perfect way to determine if a user is online or not, because it may not always fire. User's don't always click the explicit logout button too, so that may not be a good indicator as well. But since session is 20 minutes, checking where an activity occured within the last 20 minutes is a rough indicator of logged in users...