Sessions Not Working after First Failed Login Attempt

25 views
Skip to first unread message

Neil Spear

unread,
Oct 6, 2014, 11:31:42 PM10/6/14
to pak...@googlegroups.com
The login prompt for my app isn't handling Sessions correctly. Here's the scenario:

Once at the login screen, I type in a faulty username and password to fail the login attempt.
Second login attempt, I type in correct credentials. But the app redirects to the index of the app.

If using the correct credentials the first time, the app successfully redirects to the desired page.


I'm not sure how to handle the session management on the failed attempt while still displaying the necessary errors. Thoughts?

rjclardy

unread,
Oct 7, 2014, 10:38:59 AM10/7/14
to pak...@googlegroups.com
Hi Neil,

Are you binding in the login form's attributes (e.g. action, method) from the backend or are they hardcoded in the html? It sounds like they aren't being bound correctly after an invalid login attempt, but I'd need more info to know for sure. 

If you don't mind posting a gist with the following items I'll be happy to take a look:
  • html for your login form
  • backend code responsible for originally presenting the login
  • backend code responsible for handling the login attempt
Thanks,
Ryan

Neil Spear

unread,
Oct 8, 2014, 6:06:07 PM10/8/14
to pak...@googlegroups.com
Typically, what directory items are you needing?

These are my assumptions of where you're trying to look:
HTML in 'views' folder
Backend code for original presentation of login in "lib/routes"
Backend code for handling the login attempt in "lib/routes"
?

-Neil

Ryan Clardy

unread,
Oct 8, 2014, 7:22:24 PM10/8/14
to pak...@googlegroups.com
That's correct, that should be everything I need. Though just to be clear, I don't need everything in your views directory, just the HTML for your login form.

--
Ryan Clardy | MB


--
You received this message because you are subscribed to the Google Groups "Pakyow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pakyow+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Neil Spear

unread,
Oct 10, 2014, 4:58:07 PM10/10/14
to pak...@googlegroups.com
Ryan,

Here's a gist:

Let me know if there's other info I need to provide.

-Neil

Bryan Powell

unread,
Oct 12, 2014, 5:35:55 PM10/12/14
to pak...@googlegroups.com
Have you declared the `:session` as restful in its associated binder?

Bryan P.

Neil Spear

unread,
Oct 12, 2014, 10:21:06 PM10/12/14
to pak...@googlegroups.com
Yes. Sessions is declared as restful.

Bryan Powell

unread,
Oct 13, 2014, 10:17:42 AM10/13/14
to pak...@googlegroups.com
Okay, try replacing line 26 of sessions.rb with this:

ctx.bind(Session.new)

Bryan P.

On Sun, Oct 12, 2014 at 9:21 PM, Neil Spear <spe...@gmail.com> wrote:
Yes. Sessions is declared as restful.

Neil Spear

unread,
Oct 13, 2014, 12:38:19 PM10/13/14
to pak...@googlegroups.com
I tried that and no change.

Bryan Powell

unread,
Oct 13, 2014, 1:11:35 PM10/13/14
to pak...@googlegroups.com
Can you Gist the HTML (from view-source in the browser) after the initial failed login attempt?

Bryan P.

Neil Spear

unread,
Oct 13, 2014, 10:30:48 PM10/13/14
to pak...@googlegroups.com
Here 'tis. I'm not sure what you're looking for, though.


-Neil

Neil Spear

unread,
Oct 13, 2014, 10:32:45 PM10/13/14
to pak...@googlegroups.com
Try again, the embed didn't work.


-Neil

bryanp

unread,
Oct 14, 2014, 9:40:00 PM10/14/14
to pak...@googlegroups.com
Ok, I reproduced this in a test app. It appears to be a bug. If you reorder lines 25/26 in sessions.rb, it works as expected. I'll be digging into exactly what's going on here, but in the meantime let me know if changing the lines makes it work for you.

Bryan P.

Neil Spear

unread,
Oct 16, 2014, 12:11:29 AM10/16/14
to pak...@googlegroups.com
That did the trick! Thanks Bryan and Ryan. 

As a note, now when the login validation fails, the form fields for password don't cleared out. It did before the line switch. This is a nuisance which I'll have to track down.


-Neil

bryanp

unread,
Oct 16, 2014, 11:51:21 AM10/16/14
to pak...@googlegroups.com
You'll likely want to bind `Session.new` rather than `session`.

Figured out what was causing the issue and it's actually already fixed in the upcoming 0.8.1 release.

Bryan P.
Reply all
Reply to author
Forward
0 new messages