+ Continuous integration for software projects on Gitea
+
+ <% end %>
+
+
+
+
+
+
+
+
+
+
<% end %>
diff --git a/app/views/shared/_admin_nav.html.erb b/app/views/shared/_admin_nav.html.erb
index dd8c8b8..7762431 100644
--- a/app/views/shared/_admin_nav.html.erb
+++ b/app/views/shared/_admin_nav.html.erb
@@ -1,7 +1,7 @@
<%= link_to "Dashboard", admin_root_path,
class: main_nav_class(@current_section, :dashboard) %>
-<%= link_to "Users", admin_ldap_users_path,
- class: main_nav_class(@current_section, :ldap_users) %>
+<%= link_to "Users", admin_users_path,
+ class: main_nav_class(@current_section, :users) %>
<%= link_to "Invitations", admin_invitations_path,
class: main_nav_class(@current_section, :invitations) %>
<%= link_to "Donations", admin_donations_path,
diff --git a/config/application.rb b/config/application.rb
index 2e9e8ed..3731f5a 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -22,7 +22,7 @@ Bundler.require(*Rails.groups)
module Akkounts
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
- config.load_defaults 6.0
+ config.load_defaults 7.0
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
diff --git a/config/initializers/pagy.rb b/config/initializers/pagy.rb
new file mode 100644
index 0000000..16b8843
--- /dev/null
+++ b/config/initializers/pagy.rb
@@ -0,0 +1,250 @@
+# frozen_string_literal: true
+
+# Pagy initializer file (6.0.2)
+# Customize only what you really need and notice that the core Pagy works also without any of the following lines.
+# Should you just cherry pick part of this file, please maintain the require-order of the extras
+
+
+# Pagy DEFAULT Variables
+# See https://ddnexus.github.io/pagy/docs/api/pagy#variables
+# All the Pagy::DEFAULT are set for all the Pagy instances but can be overridden per instance by just passing them to
+# Pagy.new|Pagy::Countless.new|Pagy::Calendar::*.new or any of the #pagy* controller methods
+
+
+# Instance variables
+# See https://ddnexus.github.io/pagy/docs/api/pagy#instance-variables
+# Pagy::DEFAULT[:page] = 1 # default
+# Pagy::DEFAULT[:items] = 20 # default
+# Pagy::DEFAULT[:outset] = 0 # default
+
+
+# Other Variables
+# See https://ddnexus.github.io/pagy/docs/api/pagy#other-variables
+# Pagy::DEFAULT[:size] = [1,4,4,1] # default
+# Pagy::DEFAULT[:page_param] = :page # default
+# The :params can be also set as a lambda e.g ->(params){ params.exclude('useless').merge!('custom' => 'useful') }
+# Pagy::DEFAULT[:params] = {} # default
+# Pagy::DEFAULT[:fragment] = '#fragment' # example
+# Pagy::DEFAULT[:link_extra] = 'data-remote="true"' # example
+# Pagy::DEFAULT[:i18n_key] = 'pagy.item_name' # default
+# Pagy::DEFAULT[:cycle] = true # example
+# Pagy::DEFAULT[:request_path] = "/foo" # example
+
+
+# Extras
+# See https://ddnexus.github.io/pagy/categories/extra
+
+
+# Backend Extras
+
+# Arel extra: For better performance utilizing grouped ActiveRecord collections:
+# See: https://ddnexus.github.io/pagy/docs/extras/arel
+# require 'pagy/extras/arel'
+
+# Array extra: Paginate arrays efficiently, avoiding expensive array-wrapping and without overriding
+# See https://ddnexus.github.io/pagy/docs/extras/array
+# require 'pagy/extras/array'
+
+# Calendar extra: Add pagination filtering by calendar time unit (year, quarter, month, week, day)
+# See https://ddnexus.github.io/pagy/docs/extras/calendar
+# require 'pagy/extras/calendar'
+# Default for each unit
+# Pagy::Calendar::Year::DEFAULT[:order] = :asc # Time direction of pagination
+# Pagy::Calendar::Year::DEFAULT[:format] = '%Y' # strftime format
+#
+# Pagy::Calendar::Quarter::DEFAULT[:order] = :asc # Time direction of pagination
+# Pagy::Calendar::Quarter::DEFAULT[:format] = '%Y-Q%q' # strftime format
+#
+# Pagy::Calendar::Month::DEFAULT[:order] = :asc # Time direction of pagination
+# Pagy::Calendar::Month::DEFAULT[:format] = '%Y-%m' # strftime format
+#
+# Pagy::Calendar::Week::DEFAULT[:order] = :asc # Time direction of pagination
+# Pagy::Calendar::Week::DEFAULT[:format] = '%Y-%W' # strftime format
+#
+# Pagy::Calendar::Day::DEFAULT[:order] = :asc # Time direction of pagination
+# Pagy::Calendar::Day::DEFAULT[:format] = '%Y-%m-%d' # strftime format
+#
+# Uncomment the following lines, if you need calendar localization without using the I18n extra
+# module LocalizePagyCalendar
+# def localize(time, opts)
+# ::I18n.l(time, **opts)
+# end
+# end
+# Pagy::Calendar.prepend LocalizePagyCalendar
+
+# Countless extra: Paginate without any count, saving one query per rendering
+# See https://ddnexus.github.io/pagy/docs/extras/countless
+# require 'pagy/extras/countless'
+# Pagy::DEFAULT[:countless_minimal] = false # default (eager loading)
+
+# Elasticsearch Rails extra: Paginate `ElasticsearchRails::Results` objects
+# See https://ddnexus.github.io/pagy/docs/extras/elasticsearch_rails
+# Default :pagy_search method: change only if you use also
+# the searchkick or meilisearch extra that defines the same
+# Pagy::DEFAULT[:elasticsearch_rails_pagy_search] = :pagy_search
+# Default original :search method called internally to do the actual search
+# Pagy::DEFAULT[:elasticsearch_rails_search] = :search
+# require 'pagy/extras/elasticsearch_rails'
+
+# Headers extra: http response headers (and other helpers) useful for API pagination
+# See http://ddnexus.github.io/pagy/extras/headers
+# require 'pagy/extras/headers'
+# Pagy::DEFAULT[:headers] = { page: 'Current-Page',
+# items: 'Page-Items',
+# count: 'Total-Count',
+# pages: 'Total-Pages' } # default
+
+# Meilisearch extra: Paginate `Meilisearch` result objects
+# See https://ddnexus.github.io/pagy/docs/extras/meilisearch
+# Default :pagy_search method: change only if you use also
+# the elasticsearch_rails or searchkick extra that define the same method
+# Pagy::DEFAULT[:meilisearch_pagy_search] = :pagy_search
+# Default original :search method called internally to do the actual search
+# Pagy::DEFAULT[:meilisearch_search] = :ms_search
+# require 'pagy/extras/meilisearch'
+
+# Metadata extra: Provides the pagination metadata to Javascript frameworks like Vue.js, react.js, etc.
+# See https://ddnexus.github.io/pagy/docs/extras/metadata
+# you must require the frontend helpers internal extra (BEFORE the metadata extra) ONLY if you need also the :sequels
+# require 'pagy/extras/frontend_helpers'
+# require 'pagy/extras/metadata'
+# For performance reasons, you should explicitly set ONLY the metadata you use in the frontend
+# Pagy::DEFAULT[:metadata] = %i[scaffold_url page prev next last] # example
+
+# Searchkick extra: Paginate `Searchkick::Results` objects
+# See https://ddnexus.github.io/pagy/docs/extras/searchkick
+# Default :pagy_search method: change only if you use also
+# the elasticsearch_rails or meilisearch extra that defines the same
+# DEFAULT[:searchkick_pagy_search] = :pagy_search
+# Default original :search method called internally to do the actual search
+# Pagy::DEFAULT[:searchkick_search] = :search
+# require 'pagy/extras/searchkick'
+# uncomment if you are going to use Searchkick.pagy_search
+# Searchkick.extend Pagy::Searchkick
+
+
+# Frontend Extras
+
+# Bootstrap extra: Add nav, nav_js and combo_nav_js helpers and templates for Bootstrap pagination
+# See https://ddnexus.github.io/pagy/docs/extras/bootstrap
+# require 'pagy/extras/bootstrap'
+
+# Bulma extra: Add nav, nav_js and combo_nav_js helpers and templates for Bulma pagination
+# See https://ddnexus.github.io/pagy/docs/extras/bulma
+# require 'pagy/extras/bulma'
+
+# Foundation extra: Add nav, nav_js and combo_nav_js helpers and templates for Foundation pagination
+# See https://ddnexus.github.io/pagy/docs/extras/foundation
+# require 'pagy/extras/foundation'
+
+# Materialize extra: Add nav, nav_js and combo_nav_js helpers for Materialize pagination
+# See https://ddnexus.github.io/pagy/docs/extras/materialize
+# require 'pagy/extras/materialize'
+
+# Navs extra: Add nav_js and combo_nav_js javascript helpers
+# Notice: the other frontend extras add their own framework-styled versions,
+# so require this extra only if you need the unstyled version
+# See https://ddnexus.github.io/pagy/docs/extras/navs
+# require 'pagy/extras/navs'
+
+# Semantic extra: Add nav, nav_js and combo_nav_js helpers for Semantic UI pagination
+# See https://ddnexus.github.io/pagy/docs/extras/semantic
+# require 'pagy/extras/semantic'
+
+# UIkit extra: Add nav helper and templates for UIkit pagination
+# See https://ddnexus.github.io/pagy/docs/extras/uikit
+# require 'pagy/extras/uikit'
+
+# Multi size var used by the *_nav_js helpers
+# See https://ddnexus.github.io/pagy/docs/extras/navs#steps
+# Pagy::DEFAULT[:steps] = { 0 => [2,3,3,2], 540 => [3,5,5,3], 720 => [5,7,7,5] } # example
+
+
+# Feature Extras
+
+# Gearbox extra: Automatically change the number of items per page depending on the page number
+# See https://ddnexus.github.io/pagy/docs/extras/gearbox
+# require 'pagy/extras/gearbox'
+# set to false only if you want to make :gearbox_extra an opt-in variable
+# Pagy::DEFAULT[:gearbox_extra] = false # default true
+# Pagy::DEFAULT[:gearbox_items] = [15, 30, 60, 100] # default
+
+# Items extra: Allow the client to request a custom number of items per page with an optional selector UI
+# See https://ddnexus.github.io/pagy/docs/extras/items
+# require 'pagy/extras/items'
+# set to false only if you want to make :items_extra an opt-in variable
+# Pagy::DEFAULT[:items_extra] = false # default true
+# Pagy::DEFAULT[:items_param] = :items # default
+# Pagy::DEFAULT[:max_items] = 100 # default
+
+# Overflow extra: Allow for easy handling of overflowing pages
+# See https://ddnexus.github.io/pagy/docs/extras/overflow
+# require 'pagy/extras/overflow'
+# Pagy::DEFAULT[:overflow] = :empty_page # default (other options: :last_page and :exception)
+
+# Support extra: Extra support for features like: incremental, infinite, auto-scroll pagination
+# See https://ddnexus.github.io/pagy/docs/extras/support
+# require 'pagy/extras/support'
+
+# Trim extra: Remove the page=1 param from links
+# See https://ddnexus.github.io/pagy/docs/extras/trim
+# require 'pagy/extras/trim'
+# set to false only if you want to make :trim_extra an opt-in variable
+# Pagy::DEFAULT[:trim_extra] = false # default true
+
+# Standalone extra: Use pagy in non Rack environment/gem
+# See https://ddnexus.github.io/pagy/docs/extras/standalone
+# require 'pagy/extras/standalone'
+# Pagy::DEFAULT[:url] = 'http://www.example.com/subdir' # optional default
+
+
+# Rails
+# Enable the .js file required by the helpers that use javascript
+# (pagy*_nav_js, pagy*_combo_nav_js, and pagy_items_selector_js)
+# See https://ddnexus.github.io/pagy/docs/api/javascript
+
+# With the asset pipeline
+# Sprockets need to look into the pagy javascripts dir, so add it to the assets paths
+# Rails.application.config.assets.paths << Pagy.root.join('javascripts')
+
+# I18n
+
+# Pagy internal I18n: ~18x faster using ~10x less memory than the i18n gem
+# See https://ddnexus.github.io/pagy/docs/api/i18n
+# Notice: No need to configure anything in this section if your app uses only "en"
+# or if you use the i18n extra below
+#
+# Examples:
+# load the "de" built-in locale:
+# Pagy::I18n.load(locale: 'de')
+#
+# load the "de" locale defined in the custom file at :filepath:
+# Pagy::I18n.load(locale: 'de', filepath: 'path/to/pagy-de.yml')
+#
+# load the "de", "en" and "es" built-in locales:
+# (the first passed :locale will be used also as the default_locale)
+# Pagy::I18n.load({ locale: 'de' },
+# { locale: 'en' },
+# { locale: 'es' })
+#
+# load the "en" built-in locale, a custom "es" locale,
+# and a totally custom locale complete with a custom :pluralize proc:
+# (the first passed :locale will be used also as the default_locale)
+# Pagy::I18n.load({ locale: 'en' },
+# { locale: 'es', filepath: 'path/to/pagy-es.yml' },
+# { locale: 'xyz', # not built-in
+# filepath: 'path/to/pagy-xyz.yml',
+# pluralize: lambda{ |count| ... } )
+
+
+# I18n extra: uses the standard i18n gem which is ~18x slower using ~10x more memory
+# than the default pagy internal i18n (see above)
+# See https://ddnexus.github.io/pagy/docs/extras/i18n
+# require 'pagy/extras/i18n'
+
+# Default i18n key
+# Pagy::DEFAULT[:i18n_key] = 'pagy.item_name' # default
+
+
+# When you are done setting your own default freeze it, so it will not get changed accidentally
+Pagy::DEFAULT.freeze
diff --git a/config/routes.rb b/config/routes.rb
index cef51b7..8b4866b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,7 +1,7 @@
require 'sidekiq/web'
Rails.application.routes.draw do
- devise_for :users
+ devise_for :users, :controllers => { :confirmations => "users/confirmations" }
get 'welcome', to: 'welcome#index'
get 'check_your_email', to: 'welcome#check_your_email'
@@ -43,7 +43,7 @@ Rails.application.routes.draw do
namespace :admin do
root to: 'dashboard#index'
- get 'ldap_users', to: 'ldap_users#index'
+ resources 'users', param: 'address', only: ['index', 'show'], constraints: { address: /.*/ }
get 'invitations', to: 'invitations#index'
resources :donations
get 'lightning', to: 'lightning#index'
diff --git a/db/migrate/20230223115536_remove_ln_login_ciphertext_from_users.rb b/db/migrate/20230223115536_remove_ln_login_ciphertext_from_users.rb
new file mode 100644
index 0000000..da1bf86
--- /dev/null
+++ b/db/migrate/20230223115536_remove_ln_login_ciphertext_from_users.rb
@@ -0,0 +1,5 @@
+class RemoveLnLoginCiphertextFromUsers < ActiveRecord::Migration[7.0]
+ def change
+ remove_column :users, :ln_login_ciphertext
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6b3cf56..f87e1b0 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.0].define(version: 2023_02_17_084310) do
+ActiveRecord::Schema[7.0].define(version: 2023_02_23_115536) do
create_table "donations", force: :cascade do |t|
t.integer "user_id"
t.integer "amount_sats"
diff --git a/db/seeds.rb b/db/seeds.rb
index 98ae840..3671ad2 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -10,7 +10,7 @@ Sidekiq::Testing.inline! do
ldap.add_attribute "cn=admin,ou=kosmos.org,cn=users,dc=kosmos,dc=org", :admin, "true"
- 5.times do |n|
+ 35.times do |n|
username = Faker::Name.unique.first_name.downcase
email = Faker::Internet.unique.email
diff --git a/public/img/logos/icon_discourse.svg b/public/img/logos/icon_discourse.svg
new file mode 100644
index 0000000..4cbb8c8
--- /dev/null
+++ b/public/img/logos/icon_discourse.svg
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/public/img/logos/icon_droneci.svg b/public/img/logos/icon_droneci.svg
new file mode 100644
index 0000000..10f926a
--- /dev/null
+++ b/public/img/logos/icon_droneci.svg
@@ -0,0 +1,9 @@
+
diff --git a/public/img/logos/icon_gitea.png b/public/img/logos/icon_gitea.png
new file mode 100644
index 0000000..1538cd1
Binary files /dev/null and b/public/img/logos/icon_gitea.png differ
diff --git a/public/img/logos/icon_lightning.svg b/public/img/logos/icon_lightning.svg
new file mode 100644
index 0000000..406841e
--- /dev/null
+++ b/public/img/logos/icon_lightning.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/public/img/logos/icon_mastodon.svg b/public/img/logos/icon_mastodon.svg
new file mode 100644
index 0000000..7bd752a
--- /dev/null
+++ b/public/img/logos/icon_mastodon.svg
@@ -0,0 +1,48 @@
+
+
diff --git a/public/img/logos/icon_mediawiki.svg b/public/img/logos/icon_mediawiki.svg
new file mode 100644
index 0000000..fdadd25
--- /dev/null
+++ b/public/img/logos/icon_mediawiki.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/public/img/logos/icon_xmpp.svg b/public/img/logos/icon_xmpp.svg
new file mode 100644
index 0000000..058c67a
--- /dev/null
+++ b/public/img/logos/icon_xmpp.svg
@@ -0,0 +1,114 @@
+
+
+
+
diff --git a/spec/jobs/create_lndhub_account_job_spec.rb b/spec/jobs/create_lndhub_account_job_spec.rb
index aa2d179..51ffe2d 100644
--- a/spec/jobs/create_lndhub_account_job_spec.rb
+++ b/spec/jobs/create_lndhub_account_job_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe CreateLndhubAccountJob, type: :job do
.with { |req| req.body == '{}' }
user.reload
- expect(user.ln_login).to eq("abc123")
+ expect(user.ln_account).to eq("abc123")
expect(user.ln_password).to eq("def456")
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index ed135d9..b1724f1 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -1,7 +1,16 @@
require 'rails_helper'
RSpec.describe User, type: :model do
- let(:user) { create :user }
+ let(:user) { create :user, cn: "philipp" }
+ let(:dn) { "cn=philipp,ou=kosmos.org,cn=users,dc=kosmos,dc=org" }
+
+ describe "#address" do
+ let(:user) { build :user, cn: "jimmy", ou: "kosmos.org" }
+
+ it "returns the user address" do
+ expect(user.address).to eq("jimmy@kosmos.org")
+ end
+ end
describe "#is_admin?" do
it "returns true when admin flag is set in LDAP" do
@@ -21,11 +30,75 @@ RSpec.describe User, type: :model do
end
end
- describe "#address" do
- let(:user) { build :user, cn: "jimmy", ou: "kosmos.org" }
-
- it "returns the user address" do
- expect(user.address).to eq("jimmy@kosmos.org")
+ describe "#services_enabled" do
+ it "returns the entries from the LDAP service attribute" do
+ expect(user).to receive(:ldap_entry).and_return({
+ uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
+ service: ["discourse", "gitea", "wiki", "xmpp"]
+ })
+ expect(user.services_enabled).to eq(["discourse", "gitea", "wiki", "xmpp"])
end
end
+
+ describe "#enable_service" do
+ before do
+ allow(user).to receive(:ldap_entry).and_return({
+ uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
+ service: ["discourse", "gitea"]
+ })
+ allow(user).to receive(:dn).and_return(dn)
+ end
+
+ it "adds the service to the LDAP entry" do
+ expect_any_instance_of(LdapService).to receive(:replace_attribute)
+ .with(dn, :service, ["discourse", "gitea", "wiki"]).and_return(true)
+
+ user.enable_service(:wiki)
+ end
+
+ it "adds multiple service to the LDAP entry" do
+ expect_any_instance_of(LdapService).to receive(:replace_attribute)
+ .with(dn, :service, ["discourse", "gitea", "wiki", "xmpp"]).and_return(true)
+
+ user.enable_service([:wiki, :xmpp])
+ end
+ end
+
+ describe "#disable_service" do
+ before do
+ allow(user).to receive(:ldap_entry).and_return({
+ uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
+ service: ["discourse", "gitea", "xmpp"]
+ })
+ allow(user).to receive(:dn).and_return(dn)
+ end
+
+ it "removes the service from the LDAP entry" do
+ expect_any_instance_of(LdapService).to receive(:replace_attribute)
+ .with(dn, :service, ["discourse", "gitea"]).and_return(true)
+
+ user.disable_service(:xmpp)
+ end
+
+ it "removes multiple services from the LDAP entry" do
+ expect_any_instance_of(LdapService).to receive(:replace_attribute)
+ .with(dn, :service, ["discourse"]).and_return(true)
+
+ user.disable_service([:xmpp, "gitea"])
+ end
+ end
+
+ describe "#disable_all_services" do
+ before do
+ allow(user).to receive(:dn).and_return(dn)
+ end
+
+ it "removes all services from the LDAP entry" do
+ expect_any_instance_of(LdapService).to receive(:delete_attribute)
+ .with(dn, :service).and_return(true)
+
+ user.disable_all_services
+ end
+ end
+
end
diff --git a/tailwind.config.js b/tailwind.config.js
index 20a464f..a86d1b2 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -7,6 +7,15 @@ module.exports = {
'./app/helpers/**/*.rb',
'./app/javascript/**/*.js'
],
+ safelist: [
+ 'bg-gray-100', 'text-gray-800',
+ 'bg-red-100', 'text-red-800',
+ 'bg-yellow-100', 'text-yellow-800',
+ 'bg-green-100', 'text-green-800',
+ 'bg-blue-100', 'text-blue-800',
+ 'bg-purple-100', 'text-purple-800',
+ 'bg-pink-100', 'text-pink-800',
+ ],
theme: {
extend: {
fontFamily: {
@@ -16,5 +25,5 @@ module.exports = {
},
plugins: [
require('@tailwindcss/forms')
- ],
+ ]
}