It is convenient to use a library called Devise when creating user authentication. It is safer in terms of security than creating an authentication screen from scratch. What is important in Devise
Is. This method checks if you are logged in, and if you are not logged in, you are redirected to the login screen. Right now, I'm only familiar with the upper part, and in the future I'll need to look at the internal mechanism that has been black-boxed.