Registered user First visit url displays flash message - laravel

I would like to create middleware and check if registered user has already visited current URL and if not display flash message.
This feature i need just to show up tour on particular page so new user can understand what to do next.
I do realize that i can do it by store data in user table for each user but maybe there is another way to do such thing?
Thank you.

This may go quite complex depending on number of your routes. Why
don't you just make it simple:
1. Whenever user signup just store a session say session()->put('show_tour', true);
2. Now, show the flash-message on every page for registered user by checking this session value.
3. Make a button to disable this tour in your flash message. Make an AJAX call to destroy this session.

Related

Laravel 5: Create a multipage registration

How would I go about creating a multipage registration process in Laravel 5? I know I need to use Middleware, but I don't know how to use it for multiple views.
Add an extra column to your user's table, name it step to keep track of their registration process. Then after every successful form submit increment the step value.
You'd want to signup/register the user in the first step just so if they decide to come back you can redirect them to the correct step/view. This is also useful to remind the users by email to complete their registration.
If you don't use Ajax or any javascript related stuffs to go to the next page without reloading, store the inputs to the session and just get all the data from there.
Else if you're using Ajax/javscript/jquery, just make one big form and send all the data from the inputs.

How to implement form that requires users to validate email or phone number?

I'm trying to improve this form to make it a little more user friendly.
The main area I'm trying to improve is the validation process.
Right now, the form gets filled out on index page /, and the user is re-directed by the server to a /validate page. To improve the experience, the email or phone number is shown to the user so they can see whether they entered it correctly. (though rarely, it does happen)
I'm also not sure if the user should be given the opportunity to use another form of validation.
The one problem with the setup on the server side is storing the form information between page requests.
Currently I'm using the flash(one-time sessions) to store the email or the phone number. Once the user submits the form the session is lost.
I don't like using sessions for forms, because any time you have more than one window open (not that they should be in this case) the data can start to become unpredictable
I also don't want to use the url params for storing information, as this can have sensitive information being passed back and forth, and stored in browser history.
I was thinking I could do ajax, which I try not to use on sites facing a broad audience where someone is bound to be using an old version of IE.
The data I get from the form is stored in the database. I could use the GET method to store an id in params. If I use the id (or a random unique id) I run the risk of anyone guessing these ids and having access to other website users' email address and phone numbers.
I could also use a combination of the flash and hidden inputs with the unique id, but the danger of showing personal information is still there.

When do I call mixpanel.people.identify

How do I tell mixpanel the userID of my logged on user?
Do I need to call mixpanel.people.identify() everytime my user logs in, or only the first time that I'm creating them on mixpanel?
If only the first time, how does mixpanel know who to associate events to?
Also, once I have identified the person, will all events be tracable to that person, or do I need to call people.set() explicitly to track a generic event separately from a user-specific event?
You should call mixpanel.people.identify() every time a user logs in. You can even call it every time a page loads in a logged in state if you want.
identify sets some data in a cookie about what distinct_id the library should use when sending people data.
If you have called mixpanel.identify with the same distinct_id as mixpanel.people.identify, events that you send (with mixpanel.track) will show up under the user's profile on the Customers tab. In order for the user to show up at all, though, you will need to call mixpanel.people.set (or .add) at least once.
EDIT: mixpanel.people.identify is no longer necessary; you can just call mixpanel.identify and it will set both.

asp.net mvc 3 - sending an email and getting the return for validation a task (registration, form validation...)

I am having a register form that user fill in, once the form fill in, the registration is postponed till the user recieve an email to check that his email is ok, then when he reply the email, the registration is fully proceed.
I would like also the process to be automatic, without the need for the user to entered any number ect, just the need for him to click on the email to confirm, and automatic on my side too.
I want the process to be available to some others task than the registration process as well if possible.
Do I need to do all way check/123456 with the 123456 generated or is there a better way to do, a component, nuget that can do the job ? you experiences return would be helpful
thanks
You appear to be on the right track.
I do a similar thing quite often. It isn't generic since I do not need it but you can change that quite easily.
Once a user registers I send an activation e-mail that contains a link that when clicked navigates to something such as http://domain/member/activate/id where the id is a GUID. That is all I need. I look up the member id and activate it. Chances of someone guessing a new member's id are rather slim and even if they do it is very far from a train smash.
From what I can tell you need something more generic and a bit more security. You could always create some key (like a new GUID) that you store along with the user and then the activation calls: http://domain/member/activate/id?key={the guid}. You could even encrypt the key. But that is up to you.
For something that can be re-used and is more generic you could create an activation component that contains a list of activation ids. But to then activate a specific type of entity (such as user registration or form validation) you would need to have a way to perform that on the back-end. For example, when you call http://domain/activation/activate/id internally is looks up the id and gets the type. The activation request is, of course, created when, e.g., your user registers. You would probably want to store some expiry/timeout since a user may never activate.
For each type you could have an activation mechanism on the relevant controller: member/activate/key or formvalidation/activate/key. So when you activation controller receives a request to activate it has a list of routes conigured per type and the navigates to the relevant route to perform the 'actual' activation.
Another option is to have an in-process component perform activation e.g.: an IActivator interface implemented by a MemberActivator or FormValdationActivator and then have an IActivatorProvider implementation that gives you the relevant provider based on a type (.NET Type or a string type you provider --- that's up to you).
You could even pass an ActivationRequestCommand along to a service bus endpoint if you are so inclined.
So you have many options. HTH
If you are a developer I suggest you at least try to start with the code... then ask again if you get stuck providing a sample of what you've done.
What you are looking to do is basically use a temporary url that posts to a page to complete the registration...

Sessions in Codeigniter

I am using sessions to store data from my multi step form so that when the user completes all three sections of the form then the information is inserted in to the database. I have built the form so that the user can go back to any stage and modify the information they have submitted, the thing is though, the values that repopulate the form are stored in sessions so if the user leaves the form page and goes elsewhere in the website and then returns to the form the information is still in the form…is there a better way to do this? I want the data destroyed if they leave the form…
Thanks
Assuming your form exists only in one controller and isn't spread across multiple ones, you could simply unset all session values in the __construct of every other controller. (You could extend the base controller if you have lots to save the hassle of adding this functionality to many.
That way if the user visits another section, the values will be lost, but providing they remain within the "form" they can remain intact.
You could with JavaScript and the unload event, but it'll prove tricky since unload may fire with each "section" of the form.

Resources