From 589e46bc6361dcaaff96fa949a91ccdf81ed97b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Sat, 18 Mar 2023 13:43:23 +0700 Subject: [PATCH] Replace hardcoded domains with primary domain setting --- app/controllers/admin/users_controller.rb | 2 +- app/controllers/signup_controller.rb | 4 ++-- app/controllers/webhooks_controller.rb | 2 +- app/services/create_account.rb | 2 +- app/views/admin/donations/_form.html.erb | 2 +- app/views/devise/passwords/new.html.erb | 2 +- app/views/devise/sessions/new.html.erb | 2 +- app/views/signup/steps.html.erb | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 7544f55..71cac46 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -4,7 +4,7 @@ class Admin::UsersController < Admin::BaseController def index ldap = LdapService.new - @ou = params[:ou] || "kosmos.org" + @ou = params[:ou] || Setting.primary_domain @orgs = ldap.fetch_organizations @pagy, @users = pagy(User.where(ou: @ou).order(cn: :asc)) diff --git a/app/controllers/signup_controller.rb b/app/controllers/signup_controller.rb index bfbf02e..c21820b 100644 --- a/app/controllers/signup_controller.rb +++ b/app/controllers/signup_controller.rb @@ -88,7 +88,7 @@ class SignupController < ApplicationController if session[:new_user].present? @user = User.new(session[:new_user]) else - @user = User.new(ou: "kosmos.org") + @user = User.new(ou: Setting.primary_domain) end end @@ -98,7 +98,7 @@ class SignupController < ApplicationController CreateAccount.call( username: @user.cn, - domain: "kosmos.org", + domain: Setting.primary_domain, email: @user.email, password: @user.password, invitation: @invitation diff --git a/app/controllers/webhooks_controller.rb b/app/controllers/webhooks_controller.rb index 7025580..30470e1 100644 --- a/app/controllers/webhooks_controller.rb +++ b/app/controllers/webhooks_controller.rb @@ -30,7 +30,7 @@ class WebhooksController < ApplicationController def notify_xmpp(address, amt_sats, memo) payload = { type: "normal", - from: "kosmos.org", # TODO domain config + from: Setting.primary_domain, to: address, subject: "Sats received!", body: "#{helpers.number_with_delimiter amt_sats} sats received in your Lightning wallet:\n> #{memo}" diff --git a/app/services/create_account.rb b/app/services/create_account.rb index d3b949f..8c732cf 100644 --- a/app/services/create_account.rb +++ b/app/services/create_account.rb @@ -1,7 +1,7 @@ class CreateAccount < ApplicationService def initialize(args) @username = args[:username] - @domain = args[:ou] || "kosmos.org" + @domain = args[:ou] || Setting.primary_domain @email = args[:email] @password = args[:password] @invitation = args[:invitation] diff --git a/app/views/admin/donations/_form.html.erb b/app/views/admin/donations/_form.html.erb index b04562a..f780a2e 100644 --- a/app/views/admin/donations/_form.html.erb +++ b/app/views/admin/donations/_form.html.erb @@ -12,7 +12,7 @@
<%= form.label :user_id %> - <%= form.collection_select :user_id, User.where(ou: "kosmos.org").order(:cn), :id, :cn, {} %> + <%= form.collection_select :user_id, User.where(ou: Setting.primary_domain).order(:cn), :id, :cn, {} %> <%= form.label :amount_sats, "Amount BTC (sats)" %> <%= form.number_field :amount_sats %> diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb index a0345f3..a20e563 100644 --- a/app/views/devise/passwords/new.html.erb +++ b/app/views/devise/passwords/new.html.erb @@ -10,7 +10,7 @@

<%= f.text_field :cn, autofocus: true, autocomplete: "username", required: true, class: "relative grow"%> - @ kosmos.org + @ <%= Setting.primary_domain %>

diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 22ff5be..d3d02e0 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -14,7 +14,7 @@

<%= f.text_field :cn, autofocus: true, autocomplete: "username", required: true, class: "relative grow", tabindex: "1" %> - @ kosmos.org + @ <%= Setting.primary_domain %>

diff --git a/app/views/signup/steps.html.erb b/app/views/signup/steps.html.erb index ffc8a23..0eeec71 100644 --- a/app/views/signup/steps.html.erb +++ b/app/views/signup/steps.html.erb @@ -10,7 +10,7 @@ <%= f.text_field :cn, autofocus: true, autocomplete: "username", required: true, class: "relative grow text-xl"%> - @ kosmos.org + @ <%= Setting.primary_domain %>