Welcome Guest, Not a member yet? Register   Sign In
Sign ups and logins elegantly in both code and user experience

(This post was last modified: 01-24-2015, 04:26 AM by DreamOfSleeping. Edit Reason: for clarity )

I've been working on the login and signup part of my website. It was going pretty well. First I made the login form on the same page as the websites homepage, and the signup page open up in a new link. I got some javascript to help check it out and display errors before sending to be checked again in php.

But then I started working on what my website might look like, and I wasn't so keen on having the sign in form on the home page.

When you have a sign in form you need, the email input, the password input, the remember me checkbox, and the forgot password link. Which is a lot of stuff to have on your page, and limits how it would look. So I thought I might just have a login button that pops up a login form.

Now I've done that, I'm not sure how to handle it. I thought I'll send it to a separate login controller, and that could check to make sure it's ok, then redirect the user back to the homepage if there were errors. But then I have to know to have the login pop up box open and show the errors. And I'm not sure how to do that. It seems a bit messy too. [edit where I say "know to have the login pop up box open" I already know how to do that with javascript but I mean as it is redirected it needs to know that the user has already opened it.]

So I'm asking for advice, on if I were to do the popup box how would I handle it, with regards to breaking things up into different controllers. Also some general advice on handling logins and signups in an elegant way, but that's still pretty simple for a beginner like me. I'm trying to make a pretty complex website and the way I'm going I'll still be on the login form next year!

I guess I was pushing my luck with such a long overblown question. I've decided to just go with having a pop up login form. If you make any errors you will be taken to another login page with errors on it. Exactly what this website does!

I have done something similar. Over time, I ran into trouble because not all mobile devices handle popups consistently and I needed to maintain mobile compatibility. I decided that while I did not want a form on the home page, I also did not want to maintain a popup over time. I opted for a separate, responsive page, that will forward the user back to where they came from.

The handy Ion-Auth Library helped me with this.

Dream of Sleeping

I would suggest using a third party login library such as DX-Auth (Or any of the others that are good).  They have all the code in them to handle the permissions as well as some hooks to check for login.  

In previous applications with DX-Auth all you have to do it install the software and tables.  You can use the screens that are provided to do the user admin.  Then you can setup the uri permissions and place the permissions check in the constructor of each controller.

You can also use a hook to check permissions if you want.

The bulk of the hard work is done for you and you don't have to use the modal unless you really want to.

Hope this helps.

Theme © iAndrew 2016 - Forum software by © MyBB