Ruby on Rails

Authentication & Authorization

Devise (web sessions), has_secure_password, cookies, JWT (API authentication), Pundit, CanCanCan

22 preguntas de entrevista·
Mid-Level
1

What is Devise in the Rails ecosystem?

Respuesta

Devise is a flexible and complete authentication gem for Rails, built on Warden. It provides pre-configured modules to handle registration, login, password recovery, email confirmation, account locking and more. Devise is the most popular authentication solution in the Rails ecosystem due to its ease of integration and modularity.

2

What are the most commonly used Devise modules in a standard Rails application?

Respuesta

Devise offers a modular architecture where each feature is a separable module. The most common modules are database_authenticatable (password authentication), registerable (registration), recoverable (password recovery), rememberable ('remember me' cookie), validatable (email and password validations), confirmable (email confirmation) and lockable (locking after failures).

3

How to protect a controller action so it is only accessible to logged-in users with Devise?

Respuesta

Devise provides the authenticate_user! helper that can be used as a before_action in controllers. This filter checks if a user is logged in and redirects to the login page if not. It can be applied to all actions or limited with only or except. The helper name depends on the model (authenticate_admin! for an Admin model).

4

Which Devise helper allows accessing the currently logged-in user in a view or controller?

5

How to customize Devise views (login forms, registration, etc.) in a Rails application?

+19 preguntas de entrevista

Domina Ruby on Rails para tu próxima entrevista

Accede a todas las preguntas, flashcards, tests técnicos, ejercicios de code review y simuladores de entrevista.

Empieza gratis