mirror of
https://github.com/usetrmnl/terminus.git
synced 2026-08-13 14:29:27 -07:00
link:https://github.com/simplecov-ruby/simplecov/blob/main/CHANGELOG.md#100-2026-07-12[Details]. This includes the following: * My long standing bug has been fixed which allows for implicit elses to be ignored. This cleans up code related to using monads with pattern matching which is nice to see. * We still can't enable ERB code coverage (this is why the templates are skipped). I've logged a few more new bugs on the SimpleCov side to tackle. This might take a while because I noticed Erik Berlin logged issues with Ruby core in order to make this possible. * Use of the *strict* profile ensures all code committed to this project must be 100%. This also cleans up having to be explicit about this. Milestone: patch
43 lines
861 B
Ruby
43 lines
861 B
Ruby
# auto_register: false
|
|
# frozen_string_literal: true
|
|
|
|
require "dry/monads"
|
|
require "hanami/action"
|
|
require "initable"
|
|
|
|
module Terminus
|
|
# The application base action.
|
|
class Action < Hanami::Action
|
|
include Dry::Monads[:result]
|
|
|
|
before :authorize
|
|
|
|
protected
|
|
|
|
def authorize request, response
|
|
rodauth = request.env["rodauth"]
|
|
|
|
return unless rodauth
|
|
|
|
handle_rodauth_redirect(rodauth, response) { rodauth.require_account }
|
|
|
|
response[:current_user_id] = rodauth.account_id
|
|
end
|
|
|
|
private
|
|
|
|
def handle_rodauth_redirect rodauth, response
|
|
halted = catch(:halt) { yield }
|
|
|
|
return unless halted
|
|
|
|
code, headers, body = *halted
|
|
|
|
rodauth.flash.next.each { |key, value| response.flash[key] = value }
|
|
response.redirect headers["Location"], code
|
|
|
|
throw :halt, [code, body]
|
|
end
|
|
end
|
|
end
|