diff --git a/.env.example b/.env.example index ef2f5834d..c7ee5ad4f 100644 --- a/.env.example +++ b/.env.example @@ -6,7 +6,7 @@ POSTGRES_USER=sofia_development POSTGRES_PASSWORD=1234567890abcdef POSTGRES_HOST=localhost -BANANA_CLIENT_ID= -BANANA_CLIENT_SECRET= +AMBER_CLIENT_ID= +AMBER_CLIENT_SECRET= DOCKER_PASSWORD=somethingsomething diff --git a/README.md b/README.md index 94962a7e5..7d13a30f9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Alpha SOFIA [![Continuous Integration](https://github.com/csvalpha/sofia/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/csvalpha/sofia/actions/workflows/continuous-integration.yml) [![Continuous Delivery](https://github.com/csvalpha/sofia/actions/workflows/continuous-delivery.yml/badge.svg)](https://github.com/csvalpha/sofia/actions/workflows/continuous-delivery.yml) -The source code belonging to Alpha SOFIA. It is a system built with Ruby on Rails with Turbolinks and a little VueJS, used to manage orders in our own bar "Flux". Users authenticate via OAuth API (currently "Alpha Banana") to see how much credit they got left, or to be able to register new orders and/or payments. +The source code belonging to Alpha SOFIA. It is a system built with Ruby on Rails with Turbolinks and a little VueJS, used to manage orders in our own bar "Flux". Users authenticate via OAuth API (currently "Alpha AMBER") to see how much credit they got left, or to be able to register new orders and/or payments. Use this repository to build upon, use as-is, learn from it, prove a point or whatever 😏 @@ -18,8 +18,8 @@ _On Linux-like systems_ - Yarn - Postgresql 9.5+ - Running versions of - - Alpha Banana API - - Alpha Banana UI (for logging in) + - Alpha AMBER API + - Alpha AMBER UI (for logging in) ## Installation @@ -28,7 +28,7 @@ _On Linux-like systems_ 1. `bundle install` (might take a couple of minutes) 1. `yarn` 1. `bundle exec rails db:setup` - 1. `bundle exec rails s -p 5000` (port specified so it doesn't use the same as Banana API) + 1. `bundle exec rails s -p 5000` (port specified so it doesn't use the same as AMBER API) 1. Go to http://localhost:5000 and you should see SOFIA running 1. Copy `.env.example` to `.env` with `cp .env.example .env` and edit the values where necessary 1. (When you want to use the invoice module) Follow https://github.com/zakird/wkhtmltopdf_binary_gem#installation-and-usage @@ -51,19 +51,19 @@ $ EDITOR="code --wait" bundle exec rails credentials:edit ### OAuth configuration -In OAuth Banana (github.com/csvalpha/alpha-banana-api), execute the following command (in `rails console`): +In OAuth AMBER (github.com/csvalpha/amber-api), execute the following command (in `rails console`): ```ruby -app = Doorkeeper::Application.create(name: 'SOFIA - Streepsysteem der C.S.V. Alpha', redirect_uri: 'http://localhost:5000/users/auth/banana_oauth2/callback', scopes: 'public tomato') +app = Doorkeeper::Application.create(name: 'SOFIA - Streepsysteem der C.S.V. Alpha', redirect_uri: 'http://localhost:5000/users/auth/amber_oauth2/callback', scopes: 'public tomato') app.uid app.plaintext_secret ``` -Next, copy the uid and plaintext secret to the `.env` in SOFIA (as `banana_client_id` and `banana_client_secret`). +Next, copy the uid and plaintext secret to the `.env` in SOFIA (as `amber_client_id` and `amber_client_secret`). ### Configuring roles -Users can have roles in SOFIA, namely Treasurer ("SB-penningmeester") and/or Main Bartender ("Hoofdtapper"). A user can also log in without a role. These roles are derived from the groups the user is in. These groups are saved in the Banana API. +Users can have roles in SOFIA, namely Treasurer ("SB-penningmeester") and/or Main Bartender ("Hoofdtapper"). A user can also log in without a role. These roles are derived from the groups the user is in. These groups are saved in the AMBER API. Roles are created in the following way during the seeding: @@ -75,8 +75,8 @@ Role.create(role_type: :main_bartender, group_uid: 2) ## Deploying -Deploying procedure is the same as for the Banana project. -See [DEPLOY.md](https://github.com/csvalpha/alpha-banana-api/blob/master/DEPLOY.md) for that. +Deploying procedure is the same as for the AMBER project. +See [DEPLOY.md](https://github.com/csvalpha/amber-api/blob/master/DEPLOY.md) for that. ## Contributing diff --git a/app/controllers/callbacks_controller.rb b/app/controllers/callbacks_controller.rb index 9ad21a44d..04e15c358 100644 --- a/app/controllers/callbacks_controller.rb +++ b/app/controllers/callbacks_controller.rb @@ -1,5 +1,5 @@ class CallbacksController < Devise::OmniauthCallbacksController - def banana_oauth2 + def amber_oauth2 user = User.from_omniauth(request.env['omniauth.auth']) if user.persisted? diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1c0732c0f..8a18119bb 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -7,7 +7,7 @@ def index # rubocop:disable Metrics/AbcSize, Metrics/MethodLength authorize User @manual_users = User.manual.active.order(:name) - @amber_users = User.in_banana.active.order(:name) + @amber_users = User.in_amber.active.order(:name) @inactive_users = User.inactive.order(:name) @users_credits = User.calculate_credits @@ -66,7 +66,7 @@ def refresh_user_list find_or_create_user(user_json) end - users_not_in_json = User.active.in_banana.where.not(uid: users_json.pluck('id')) + users_not_in_json = User.active.in_amber.where.not(uid: users_json.pluck('id')) users_not_in_json.each(&:archive!) send_slack_users_refresh_notification @@ -86,9 +86,9 @@ def api_token return @token if @token options = { grant_type: 'client_credentials', - client_id: Rails.application.config.x.banana_client_id, - client_secret: Rails.application.config.x.banana_client_secret } - token_response = RestClient.post "#{Rails.application.config.x.banana_api_url}/api/v1/oauth/token", options + client_id: Rails.application.config.x.amber_client_id, + client_secret: Rails.application.config.x.amber_client_secret } + token_response = RestClient.post "#{Rails.application.config.x.amber_api_url}/api/v1/oauth/token", options @token = JSON.parse(token_response)['access_token'] end @@ -112,12 +112,12 @@ def send_slack_users_refresh_notification # :nocov: SlackMessageJob.perform_later("User ##{current_user.id} (#{current_user.name}) "\ - "is importing users from Banana (#{Rails.application.config.x.banana_api_host})") + "is importing users from Amber (#{Rails.application.config.x.amber_api_host})") # :nocov: end def users_json - JSON.parse(RestClient.get("#{Rails.application.config.x.banana_api_url}/api/v1/users?filter[group]=Leden", + JSON.parse(RestClient.get("#{Rails.application.config.x.amber_api_url}/api/v1/users?filter[group]=Leden", 'Authorization' => "Bearer #{api_token}"))['data'] end @@ -127,7 +127,7 @@ def find_or_create_user(user_json) # rubocop:disable Metrics/AbcSize u.name = User.full_name_from_attributes(fields['first_name'], fields['last_name_prefix'], fields['last_name']) - u.provider = 'banana_oauth2' + u.provider = 'amber_oauth2' u.avatar_thumb_url = fields['avatar_thumb_url'] u.email = fields['email'] u.birthday = fields['birthday'] diff --git a/app/controllers/zatladder_controller.rb b/app/controllers/zatladder_controller.rb index c789ef976..06d230f29 100644 --- a/app/controllers/zatladder_controller.rb +++ b/app/controllers/zatladder_controller.rb @@ -24,8 +24,8 @@ def current_year end def zatladder_spendings(from, to) - @users_spendings = User.in_banana.calculate_spendings(from: from, to: to) - zatladder = User.in_banana.select(:id, :name).map do |user| + @users_spendings = User.in_amber.calculate_spendings(from: from, to: to) + zatladder = User.in_amber.select(:id, :name).map do |user| { id: user.id, name: user.name, diff --git a/app/jobs/credit_insufficient_notification_job.rb b/app/jobs/credit_insufficient_notification_job.rb index 587fbbe79..6297fa670 100644 --- a/app/jobs/credit_insufficient_notification_job.rb +++ b/app/jobs/credit_insufficient_notification_job.rb @@ -30,7 +30,7 @@ def send_notification_delivery_reports(success_count, unnotifyable_users) return unless Rails.env.production? || Rails.env.staging? - SlackMessageJob.perform_later("Er is voor #{Rails.application.config.x.banana_api_host} een saldomail "\ + SlackMessageJob.perform_later("Er is voor #{Rails.application.config.x.amber_api_host} een saldomail "\ "verstuurd naar #{success_count} mensen, en #{unnotifyable_users.count} saldomail(s) kon(den) niet "\ 'verzonden worden door het ontbreken van een e-mail adres.') diff --git a/app/models/user.rb b/app/models/user.rb index dc001b052..eddc6bb2b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,5 @@ class User < ApplicationRecord - devise :omniauthable, omniauth_providers: [:banana_oauth2] + devise :omniauthable, omniauth_providers: [:amber_oauth2] has_many :orders, dependent: :destroy has_many :order_rows, through: :orders, dependent: :destroy has_many :credit_mutations, dependent: :destroy @@ -12,7 +12,7 @@ class User < ApplicationRecord validates :uid, uniqueness: true, allow_blank: true validate :no_deactivation_when_nonzero_credit - scope :in_banana, (-> { where(provider: 'banana_oauth2') }) + scope :in_amber, (-> { where(provider: 'amber_oauth2') }) scope :manual, (-> { where(provider: nil) }) scope :active, (-> { where(deactivated: false) }) scope :inactive, (-> { where(deactivated: true) }) @@ -25,7 +25,7 @@ def credit def avatar_thumb_or_default_url return '/images/avatar_thumb_default.png' unless avatar_thumb_url - "#{Rails.application.config.x.banana_api_url}#{avatar_thumb_url}" + "#{Rails.application.config.x.amber_api_url}#{avatar_thumb_url}" end def age diff --git a/app/views/partials/_login_prompt.html.erb b/app/views/partials/_login_prompt.html.erb index 6c72a730d..46641cae6 100644 --- a/app/views/partials/_login_prompt.html.erb +++ b/app/views/partials/_login_prompt.html.erb @@ -8,7 +8,7 @@

Log in with a C.S.V. Alpha account. -

<%= link_to('Sign in with C.S.V. Alpha', user_banana_oauth2_omniauth_authorize_path, class: 'btn btn-primary btn-block', method: :post) %> +

<%= link_to('Sign in with C.S.V. Alpha', user_amber_oauth2_omniauth_authorize_path, class: 'btn btn-primary btn-block', method: :post) %>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index cdd82167c..d6d0eb252 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -55,8 +55,8 @@ Accountbron - <% if @user.provider == 'banana_oauth2' %> - <%= link_to 'C.S.V. Alpha', "#{Rails.application.config.x.banana_api_url}/users/#{@user.uid}" %> + <% if @user.provider == 'amber_oauth2' %> + <%= link_to 'C.S.V. Alpha', "#{Rails.application.config.x.amber_api_url}/users/#{@user.uid}" %> <% else %> <%= @user.provider || 'Handmatig aangemaakt' %> diff --git a/config/application.rb b/config/application.rb index 7c825a490..59c5a8498 100644 --- a/config/application.rb +++ b/config/application.rb @@ -24,15 +24,15 @@ class Application < Rails::Application # See https://github.com/kickstarter/rack-attack#getting-started config.middleware.use Rack::Attack - config.x.banana_api_host = credentials.dig(Rails.env.to_sym, :banana_host) - config.x.banana_api_url = "#{Rails.env.development? ? 'http' : 'https'}://#{credentials.dig(Rails.env.to_sym, :banana_host)}" + config.x.amber_api_host = credentials.dig(Rails.env.to_sym, :amber_host) + config.x.amber_api_url = "#{Rails.env.development? ? 'http' : 'https'}://#{credentials.dig(Rails.env.to_sym, :amber_host)}" - config.x.banana_client_id = credentials.dig(Rails.env.to_sym, :banana_client_id) || ENV.fetch('BANANA_CLIENT_ID', nil) - config.x.banana_client_secret = credentials.dig( - Rails.env.to_sym, :banana_client_secret - ) || ENV.fetch('BANANA_CLIENT_SECRET', nil) + config.x.amber_client_id = credentials.dig(Rails.env.to_sym, :amber_client_id) || ENV.fetch('AMBER_CLIENT_ID', nil) + config.x.amber_client_secret = credentials.dig( + Rails.env.to_sym, :amber_client_secret + ) || ENV.fetch('AMBER_CLIENT_SECRET', nil) - config.x.banana_host = credentials.dig(Rails.env.to_sym, :banana_host) + config.x.amber_host = credentials.dig(Rails.env.to_sym, :amber_host) config.x.tomato_host = credentials.dig(Rails.env.to_sym, :tomato_host) config.x.slack_webhook = credentials.dig(Rails.env.to_sym, :slack_webhook) || '' diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index d0e3120f3..49d52e817 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -8LgLn5HWnhINbvFJluqoRRtvvDG+DeNDE9VY6fcJKYiH1xsarg3bMd5SEmBX38dDxUrVQru8DN/KZouB8b7OhqSaRffP63FQzKC/7vFJVwyQJvpLL68ugL9qgLnFAijqu5K+dR9MQ55lp3B+EU0/jlBnykispIc7Q53U1q2A12UW8vhDPsrD29Jx/Ug/OabrKJ3wHFG8+3GS41sIC69fLxLhHqsPXlksx1nMpXNvPBjLvAg6B69RmtT4tsL87baKQJM3HsU6WCZJjs3UIx9DHaqU11SgnzW6v/99B3Mau8EAp8sOX+FuWBCr3RaRTmI+LqOvSPGqo185o9w3LzxPa5ke+faciWS97XZBMyOx0O3GGvHJWoXY7DHkMR6/2pQ0yLRAtfh3TN/S54EKafJsgRaRP1I0i377+4Hg5SpdW0Noc7sknMu9SjJhRFZFLHgS87nYa9L2M3jlKYrJIG7h5voUhwe2dg1zDRihfXn870IOT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3BKUWhxFSdtoaVW5YXl1ZzolljmVuNaMlODwQwrSAyEhZ3QfyJ0zn1hCbnKnn0j0ThupLehtzhApENk+ejpa0OqHtqD0AWWDs2EeLLB0vLS8+qfRnfIrjVLI40cScaKFfoLUBWqz7Ly7Rx5mPZncaDeKVB4MMVyCQlIM/edMmnNBw12kowLvob/y29i20hhnt8iVRcy+tn/MvpOXesmdfw/hJE1y4gmIUHp4OWgJDXJSFr/h3hxG79tcvW0jSqqmdFY66NvxincClrgsofXdhJb18injyHibAalhhuIuHRWC/wLmT4aIfgTU/okLCn101MIzq2OCsqdwIPScoQTs5sPC9H+/od9OLnWfVZrd34oN1+yEvH3IvLkUjO+5WelhzKtiGM3r2+YlWhih9V+VpU6OYPWusRevR4rwFNsg4T3C7hV6B8ukrd6+zAXytMGKCSgjtbkoF2fGpjfHsPzdYJIhzonNAfyVZ/KV4epAQ3Da+VDqxhzH0HUJnBQ3ucaPMx6Kt+VjaS5X6Q=--91HDlcGnjRME192Q--FHoijSpGcnpsYnoLQ/cSSw== \ No newline at end of file diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index d1239e1c6..a58314623 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -9,6 +9,6 @@ # ==> OmniAuth require 'omniauth_strategies' - config.omniauth :banana_oauth2, Rails.application.config.x.banana_client_id, - Rails.application.config.x.banana_client_secret + config.omniauth :amber_oauth2, Rails.application.config.x.amber_client_id, + Rails.application.config.x.amber_client_secret end diff --git a/db/migrate/20220612210330_update_user_provider.rb b/db/migrate/20220612210330_update_user_provider.rb new file mode 100644 index 000000000..1baa0109b --- /dev/null +++ b/db/migrate/20220612210330_update_user_provider.rb @@ -0,0 +1,9 @@ +class UpdateUserProvider < ActiveRecord::Migration[6.1] + def up + User.where(provider: 'banana_oauth2').update(provider: 'amber_oauth2') + end + + def down + User.where(provider: 'amber_oauth2').update(provider: 'banana_oauth2') + end +end diff --git a/db/schema.rb b/db/schema.rb index 1e64b4e54..a6346f84f 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.define(version: 2021_10_10_095118) do +ActiveRecord::Schema.define(version: 2022_06_12_210330) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" diff --git a/lib/omniauth/strategies/banana_oauth2.rb b/lib/omniauth/strategies/amber_oauth2.rb similarity index 90% rename from lib/omniauth/strategies/banana_oauth2.rb rename to lib/omniauth/strategies/amber_oauth2.rb index 5c476d762..308dce245 100644 --- a/lib/omniauth/strategies/banana_oauth2.rb +++ b/lib/omniauth/strategies/amber_oauth2.rb @@ -2,11 +2,11 @@ module OmniAuth module Strategies - class BananaOauth2 < OmniAuth::Strategies::OAuth2 - option :name, 'banana_oauth2' + class AmberOauth2 < OmniAuth::Strategies::OAuth2 + option :name, 'amber_oauth2' option :client_options, - site: Rails.application.config.x.banana_api_url.to_s, + site: Rails.application.config.x.amber_api_url.to_s, authorize_url: '/oauth/authorize', token_url: '/api/v1/oauth/token' diff --git a/lib/omniauth_strategies.rb b/lib/omniauth_strategies.rb index 5fc4b6fd3..d1b80bdf2 100644 --- a/lib/omniauth_strategies.rb +++ b/lib/omniauth_strategies.rb @@ -1 +1 @@ -require 'omniauth/strategies/banana_oauth2' +require 'omniauth/strategies/amber_oauth2' diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 0ea908f64..21e16a6bb 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -23,21 +23,21 @@ end end - describe '.in_banana' do - context 'when in banana' do - subject(:user) { create(:user, provider: 'banana_oauth2') } + describe '.in_amber' do + context 'when in amber' do + subject(:user) { create(:user, provider: 'amber_oauth2') } before { user } - it { expect(described_class.in_banana).to include user } + it { expect(described_class.in_amber).to include user } end - context 'when not in banana' do + context 'when not in amber' do subject(:user) { create(:user, provider: 'another_provider') } before { user } - it { expect(described_class.in_banana).not_to include user } + it { expect(described_class.in_amber).not_to include user } end end @@ -136,7 +136,7 @@ context 'when with avatar thumb url' do subject(:user) { create(:user, avatar_thumb_url: '/test.png') } - it { expect(user.avatar_thumb_or_default_url).to eq "#{Rails.application.config.x.banana_api_url}/test.png" } + it { expect(user.avatar_thumb_or_default_url).to eq "#{Rails.application.config.x.amber_api_url}/test.png" } end context 'when without avatar thumb url' do