-
Notifications
You must be signed in to change notification settings - Fork 0
Integration with Devise
mbeauv edited this page Mar 3, 2018
·
1 revision
Devise is still a very popular sign in method in Rails. If you want to integrate the media_gallery engine with Rails. Here's the approach we use:
MediaGallery::ApplicationController.class_eval do
before_action :authenticate_end_user
def get_user_from_params
params[:auth_token] ? UrbanoeUser::EndUser.find_by_authentication_token(params[:auth_token]) : nil
end
def current_user
@current_user
end
# Authenticates the user but does not throw exception if no user present
def authenticate_end_user
@current_user = get_user_from_params()
end
def create_ability(user)
Ability.new(user)
end
end
The auth_token is the devise auth_token.