This regex:
m{^/login|/}
will match anything starting with /login, OR anything containing a forward slash. So it'll match all your routes, and the second half of your if condition will never be true, and your before hook will never redirect to /login.
If you're trying to match either the /login page OR the home page, you'll need to anchor that part of the pattern, or compare strings directly instead of a regex:
m{^/login|^/$}; # or
if($route ne '/login' and $route ne '/'){
Aaron B.
Available for small or large Perl jobs; see my home node.