diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..05ef5629c Binary files /dev/null and b/.DS_Store differ diff --git a/app/.DS_Store b/app/.DS_Store new file mode 100644 index 000000000..830c593b8 Binary files /dev/null and b/app/.DS_Store differ diff --git a/app/controllers/.DS_Store b/app/controllers/.DS_Store new file mode 100644 index 000000000..a3eee7bc4 Binary files /dev/null and b/app/controllers/.DS_Store differ diff --git a/app/controllers/repp/.DS_Store b/app/controllers/repp/.DS_Store new file mode 100644 index 000000000..fcb003e65 Binary files /dev/null and b/app/controllers/repp/.DS_Store differ diff --git a/app/controllers/repp/v1/.DS_Store b/app/controllers/repp/v1/.DS_Store new file mode 100644 index 000000000..b22dad763 Binary files /dev/null and b/app/controllers/repp/v1/.DS_Store differ diff --git a/app/controllers/repp/v1/registrar/auth_controller.rb b/app/controllers/repp/v1/registrar/auth_controller.rb new file mode 100644 index 000000000..74737e5ca --- /dev/null +++ b/app/controllers/repp/v1/registrar/auth_controller.rb @@ -0,0 +1,26 @@ +module Repp + module V1 + module Registrar + class AuthController < BaseController + api :GET, 'repp/v1/registrar/auth' + desc 'check user auth info, track user last login datetime and return data' + + def index + registrar = current_user.registrar + + data = set_values_to_data(registrar: registrar) + + render_success(data: data) + end + + private + + def set_values_to_data(registrar:) + data = current_user.as_json(only: %i[id username roles]) + data[:registrar_name] = registrar.name + data + end + end + end + end +end \ No newline at end of file diff --git a/app/controllers/repp/v1/registrar/summary_controller.rb b/app/controllers/repp/v1/registrar/summary_controller.rb new file mode 100644 index 000000000..dfb54931c --- /dev/null +++ b/app/controllers/repp/v1/registrar/summary_controller.rb @@ -0,0 +1,44 @@ +module Repp + module V1 + module Registrar + class SummaryController < BaseController + api :GET, 'repp/v1/registrar/summary' + desc 'check user summary info and return data' + + def index + registrar = current_user.registrar + + data = evaluate_data(registrar: registrar) + + render_success(data: data) + end + + private + + def evaluate_data(registrar:) + data = current_user.as_json(only: %i[id username]) + data[:registrar_name] = registrar.name + data[:last_login_date] = last_login_date + data[:balance] = { amount: registrar.cash_account&.balance, + currency: registrar.cash_account&.currency } + data[:domains] = registrar.domains.count + data[:contacts] = registrar.contacts.count + data[:phone] = registrar.phone + data[:email] = registrar.email + data[:billing_email] = registrar.billing_email + data[:billing_address] = registrar.address + data + end + + def last_login_date + q = ApiLog::ReppLog.ransack({ request_path_eq: '/repp/v1/registrar/auth', + response_code_eq: '200', + api_user_name_cont: current_user.username, + request_method_eq: 'GET' }) + q.sorts = 'id desc' + q.result.offset(1).first&.created_at + end + end + end + end +end \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 56d499289..984a949df 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -827,8 +827,7 @@ CREATE TABLE public.dnskeys ( updator_str character varying, legacy_domain_id integer, updated_at timestamp without time zone, - validation_datetime timestamp without time zone, - failed_validation_reason character varying + validation_datetime timestamp without time zone ); @@ -1196,7 +1195,6 @@ CREATE TABLE public.invoices ( buyer_vat_no character varying, issue_date date NOT NULL, e_invoice_sent_at timestamp without time zone, - payment_link character varying, CONSTRAINT invoices_due_date_is_not_before_issue_date CHECK ((due_date >= issue_date)) ); @@ -5403,9 +5401,6 @@ INSERT INTO "schema_migrations" (version) VALUES ('20220106123143'), ('20220113201642'), ('20220113220809'), -('20220124105717'), -('20220216113112'), -('20220228093211'); ('20220316140727'); diff --git a/üpõ.preinstalled_gems b/üpõ.preinstalled_gems new file mode 100644 index 000000000..0b8633422 --- /dev/null +++ b/üpõ.preinstalled_gems @@ -0,0 +1,25 @@ +FROM ghcr.io/internetee/registry:gems-latest +LABEL org.opencontainers.image.source=https://github.com/internetee/registry +ARG YARN_VER='1.22.10' +ARG RAILS_ENV +ARG SECRET_KEY_BASE + +ENV RAILS_ENV "$RAILS_ENV" +ENV SECRET_KEY_BASE "$SECRET_KEY_BASE" + +RUN npm install -g yarn@"$YARN_VER" + +RUN bash -c 'mkdir -pv -m776 {/opt/webapps/app/tmp/pids,/opt/ca,/opt/ca/newcerts}' +RUN echo -n 12 > /opt/ca/serial +RUN chmod 776 /opt/ca/serial +RUN echo '3A0e' > /opt/ca/crlnumber +RUN chmod 776 /opt/ca/crlnumber +RUN touch /opt/ca/index.txt +RUN chmod 776 /opt/ca/index.txt +WORKDIR /opt/webapps/app + +COPY . . + +RUN bundle exec rails assets:precompile + +EXPOSE 3000