Redirect to root_url when already authenticated

When you hit sessions/new in the new authentication flow it renders the session/new template without any check if an user is already authenticated. This isnt a big deal since normally a “login” button/link is displayed only when an user isnt authenticated. But to prevent an user to manually type sessions/new and create multiple sessions records do you guys think is better to have something like redirect_to some_url if authenticated? in the sessions/new action or this is irrelevant?

Also, this is the commom behavior out there, if you go to Sign in to GitHub · GitHub already being logged you will be redirected to the home page.

This can be handled in several ways. For the use case you describe a simple reroute in the sessions or login controller is a good option. For more complex cases and to keep the logic outside of the controllers you could use route constraints and advanced constraints. There is good documentation for those features in the rails guides.

my question was more like if this should be the default behavior when generating authentication with rails