File: logout.rb

package info (click to toggle)
ruby-rodauth 2.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 812 kB
  • sloc: ruby: 7,524; javascript: 100; makefile: 4
file content (38 lines) | stat: -rw-r--r-- 632 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen-string-literal: true

module Rodauth
  Feature.define(:logout, :Logout) do
    notice_flash "You have been logged out"
    loaded_templates %w'logout'
    view 'logout', 'Logout'
    additional_form_tags
    before
    after
    button 'Logout'
    redirect{require_login_redirect}
    response

    auth_methods :logout

    route do |r|
      before_logout_route

      r.get do
        logout_view
      end

      r.post do
        transaction do
          before_logout
          logout
          after_logout
        end
        logout_response
      end
    end

    def logout
      clear_session
    end
  end
end