Sha256: 11e7e6807ad3107f5758cd39516ede1e650a50e6e02fb55f5b1100a5e42ef0c8
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module Decidim module Devise # Custom Devise SessionsController to avoid namespace problems. class SessionsController < ::Devise::SessionsController include Decidim::NeedsOrganization include Decidim::LocaleSwitcher helper Decidim::TranslationsHelper helper Decidim::OmniauthHelper helper Decidim::MetaTagsHelper helper Decidim::DecidimFormHelper helper Decidim::LanguageChooserHelper helper Decidim::CookiesHelper layout "layouts/decidim/application" def after_sign_in_path_for(user) if !pending_redirect?(user) && first_login_and_not_authorized?(user) first_login_authorizations_path else super end end # Calling the `stored_location_for` method removes the key, so in order # to check if there's any pending redirect after login I need to call # this method and use the value to set a pending redirect. This is the # only way to do this without checking the session directly. def pending_redirect?(user) store_location_for(user, stored_location_for(user)) end def first_login_and_not_authorized?(user) user.is_a?(User) && user.sign_in_count == 1 && Decidim.authorization_handlers.any? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
decidim-core-0.0.5 | app/controllers/decidim/devise/sessions_controller.rb |