Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added activate users button #203

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ HYKU_ADMIN_ONLY_TENANT_CREATION=false
HYKU_DEFAULT_HOST=%{tenant}.hyku.test
HYKU_ROOT_HOST=hyku.test
HYKU_MULTITENANT=true
HYKU_USER_DEFAULT_PASSWORD=password
# Comment out these 2 for multi tenancy / Uncomment for single
# HYKU_ROOT_HOST=hyku.test
# HYKU_MULTITENANT=false
Expand Down
13 changes: 12 additions & 1 deletion app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ def destroy
if @user.present? && @user.roles.destroy_all
redirect_to hyrax.admin_users_path, notice: t('hyrax.admin.users.destroy.success', user: @user)
else
redirect_to hyrax.admin_users_path flash: { error: t('hyrax.admin.users.destroy.failure', user: @user) }
redirect_to hyrax.admin_users_path, flash: { error: t('hyrax.admin.users.destroy.failure', user: @user) }
end
end

def activate
user = User.find(params[:id])
user.password = ENV.fetch('HYKU_USER_DEFAULT_PASSWORD', 'password')

if user.save && user.accept_invitation!
redirect_to hyrax.admin_users_path, notice: t('hyrax.admin.users.activate.success', user: user)
else
redirect_to hyrax.admin_users_path, flash: { error: t('hyrax.admin.users.activate.failure', user: user) }
end
end

Expand Down
7 changes: 5 additions & 2 deletions app/views/hyrax/admin/users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@invite_roles_options.map { |r| [r.titleize, r ]},
{ prompt: 'Select a role...' },
required: false,
class: 'form-control' %>
class: 'form-control' %>
<%= f.submit t('.add'), class: 'btn btn-primary' %>
</div>
<% end %>
Expand Down Expand Up @@ -87,7 +87,10 @@
<td><%= user.accepted_or_not_invited? ? t('.status.active') : t('.status.pending') %></td>
<% if can? :destroy, User %>
<td>
<%= link_to t('.delete'), main_app.admin_user_path(user), class: 'btn btn-danger btn-sm action-delete', method: :delete, data: { confirm: t('hyrax.admin.users.destroy.confirmation', user: user.email) } %>
<%= link_to t('.delete'), main_app.admin_user_path(user), class: 'btn btn-danger btn-sm action-delete', method: :delete, data: { confirm: t('hyrax.admin.users.destroy.confirmation', user: user.email) } %>
<% if user.invited_to_sign_up? %>
<%= link_to t('.activate'), main_app.activate_admin_user_path(user.id), class: 'btn btn-primary btn-sm', method: :post, data: { confirm: t('hyrax.admin.users.activate.confirmation', user: user.email) } %>
<% end %>
</td>
<% end %>
</tr>
Expand Down
4 changes: 4 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ de:
roles_and_permissions: Benutzer und Gruppen
system_status: Systemstatus
users:
activate:
confirmation: Sind Sie sicher, dass Sie den Benutzer „%{user}“ aktivieren möchten?
failure: Benutzer „%{user}“ konnte nicht aktiviert werden.
success: Benutzer „%{user}“ wurde erfolgreich aktiviert.
destroy:
confirmation: Möchten Sie den Benutzer "%{user}" wirklich löschen? Diese Aktion lässt sich nicht rückgängig machen.
failure: Benutzer "%{user}" konnte nicht gelöscht werden.
Expand Down
4 changes: 1 addition & 3 deletions config/locales/devise_invitable.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ de:
accept: Die Einladung annehmen
accept_until: Diese Einladung wird in %{due_date} fällig.
hello: Hallo %{email}
ignore: |-
Wenn Sie die Einladung nicht akzeptieren möchten, ignorieren Sie bitte diese E-Mail.
Ihr Konto wird erst dann erstellt, wenn Sie auf den obigen Link zugreifen und Ihr Passwort festlegen.
ignore: "Wenn Sie die Einladung nicht akzeptieren möchten, ignorieren Sie bitte diese E-Mail. \nIhr Konto wird erst dann erstellt, wenn Sie auf den obigen Link zugreifen und Ihr Passwort festlegen."
someone_invited_you: Jemand hat Sie zu %{url} eingeladen, können Sie es über den Link unten akzeptieren.
subject: Einladungshinweise
time:
Expand Down
4 changes: 1 addition & 3 deletions config/locales/devise_invitable.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ es:
accept: Aceptar la invitacion
accept_until: Esta invitación será %{due_date}.
hello: Hola %{email}
ignore: |-
Si no desea aceptar la invitación, ignore este correo electrónico.
Su cuenta no se creará hasta que acceda al enlace anterior y establezca su contraseña.
ignore: "Si no desea aceptar la invitación, ignore este correo electrónico. \nSu cuenta no se creará hasta que acceda al enlace anterior y establezca su contraseña."
someone_invited_you: Alguien te ha invitado a %{url}, puedes aceptarlo a través del siguiente enlace.
subject: Instrucciones de invitación
time:
Expand Down
4 changes: 1 addition & 3 deletions config/locales/devise_invitable.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ fr:
accept: Accepter l'invitation
accept_until: Cette invitation sera due en %{due_date}.
hello: Bonjour %{email}
ignore: |-
Si vous ne souhaitez pas accepter l'invitation, ignorez ce courriel.
Votre compte ne sera créé que lorsque vous accédez au lien ci-dessus et définissez votre mot de passe.
ignore: "Si vous ne souhaitez pas accepter l'invitation, ignorez ce courriel. \nVotre compte ne sera créé que lorsque vous accédez au lien ci-dessus et définissez votre mot de passe."
someone_invited_you: Quelqu'un vous a invité %{url}, vous pouvez l'accepter par le lien ci-dessous.
subject: Instructions d'invitation
time:
Expand Down
4 changes: 1 addition & 3 deletions config/locales/devise_invitable.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ it:
accept: Accetta l'invito
accept_until: Questo invito sarà dovuto in %{due_date}.
hello: Ciao %{email}
ignore: |-
Se non desideri accettare l'invito, ignora questa email.
Il tuo account non verrà creato finché non accedi al link precedente e imposta la tua password.
ignore: "Se você não deseja aceitar o convite, ignore este e-mail. \nSua conta não será criada até você acessar o link acima e definir sua senha."
someone_invited_you: Qualcuno ti ha invitato a %{url}, puoi accettarlo tramite il link qui sotto.
subject: Istruzioni di invito
time:
Expand Down
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ en:
manage_groups: Manage Groups
system_status: System Status
users:
activate:
confirmation: Are you sure you want to activate the user "%{user}"?
failure: User "%{user}" could not be activated.
success: User "%{user}" has been successfully activated.
destroy:
confirmation: Are you sure you wish to delete the user "%{user}"? This action is irreversible.
failure: User "%{user}" could not be deleted.
Expand Down
4 changes: 4 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ es:
manage_groups: Administrar Grupos
system_status: Estado del sistema
users:
activate:
confirmation: ¿Estás seguro de que deseas activar el usuario "%{user}"?
failure: No se pudo activar el usuario "%{user}".
success: El usuario "%{user}" se ha activado correctamente.
destroy:
confirmation: ¿Estás seguro de que deseas eliminar el usuario "%{user}"? Esta acción es irreversible.
failure: El usuario "%{user}" no pudo ser eliminado.
Expand Down
4 changes: 4 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ fr:
system_status: État du système
technical: Technique
users:
activate:
confirmation: Etes-vous sûr de vouloir activer l'utilisateur "%{user}" ?
failure: L'utilisateur "%{user}" n'a pas pu être activé.
success: L'utilisateur "%{user}" a été activé avec succès.
destroy:
confirmation: Voulez-vous vraiment supprimer l'utilisateur "%{user}"? Cette action est irréversible.
failure: L'utilisateur "%{user}" n'a pas pu être supprimé.
Expand Down
4 changes: 4 additions & 0 deletions config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ it:
manage_groups: Gestisci gruppi
system_status: Stato del sistema
users:
activate:
confirmation: Sei sicuro di voler attivare l'utente "%{user}"?
failure: Impossibile attivare l'utente "%{user}".
success: L'utente "%{user}" è stato attivato con successo.
destroy:
confirmation: Sei sicuro di voler cancellare l'utente "%{user}"? Questa azione è irreversibile.
failure: L'utente "%{user}" non può essere cancellato.
Expand Down
4 changes: 4 additions & 0 deletions config/locales/pt-.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ pt-:
manage_groups: Gerenciar grupos
system_status: Status do sistema
users:
activate:
confirmation: Tem certeza de que deseja ativar o usuário "%{user}"?
failure: O usuário "%{user}" não pôde ser ativado.
success: O usuário "%{user}" foi ativado com sucesso.
destroy:
confirmation: Tem certeza de que deseja excluir o usuário "%{user}"? Esta ação é irreversível.
failure: O usuário "%{user}" não pôde ser excluído.
Expand Down
4 changes: 4 additions & 0 deletions config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ pt-BR:
manage_groups: Gerenciar grupos
system_status: Status do sistema
users:
activate:
confirmation: Tem certeza de que deseja ativar o usuário "%{user}"?
failure: O usuário "%{user}" não pôde ser ativado.
success: O usuário "%{user}" foi ativado com sucesso.
destroy:
confirmation: Tem certeza de que deseja excluir o usuário "%{user}"? Esta ação é irreversível.
failure: O usuário "%{user}" não pôde ser excluído.
Expand Down
2 changes: 1 addition & 1 deletion config/locales/simple_form.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ de:
allow_signup: Erlauben Sie Benutzern, sich bei Ihrem Repository anzumelden
cache_api: Aktiviert den Cache für API-Endpunkte. Experimental
contact_email: E-Mail-Empfänger von Nachrichten, die über das Kontaktformular gesendet werden
contact_email_to: E-Mail-Adresse, die Kontakt-E-Mails erhalten soll
contact_email_to: E-Mail-Empfänger von Nachrichten, die über das Kontaktformular gesendet werden
doi_reader: Zeigen Sie die Fähigkeit, aus Datacite zu lesen, um Datensätze zu füllen. WIP nicht verwenden
doi_writer: Schreiben Sie DOIs für Datensätze. WIP nicht verwenden
email_format: Legen Sie eine Liste von E-Mail-Domains fest, die sich bei diesem Repository anmelden dürfen, z. B. (@ubiquitypress.com @gmail.com). Lassen Sie zwischen jeder Domäne ein einzelnes Leerzeichen.
Expand Down
2 changes: 1 addition & 1 deletion config/locales/simple_form.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ es:
allow_signup: Permita que los usuarios se registren en su repositorio
cache_api: Activa la memoria caché para los puntos finales de la API. Experimental
contact_email: Destinatario de correo electrónico de los mensajes enviados a través del formulario de contacto
contact_email_to: Dirección de correo electrónico que debe recibir correos electrónicos de contacto
contact_email_to: Destinatario de correo electrónico de los mensajes enviados a través del formulario de contacto
doi_reader: Mostrar la capacidad de leer de Datacite para completar registros. WIP no usar
doi_writer: Escriba DOI para los registros. WIP no usar
email_format: Establezca una lista de dominios de correo electrónico que pueden registrarse en este repositorio, por ejemplo, (@ubiquitypress.com @gmail.com). Deje un solo espacio entre cada dominio.
Expand Down
2 changes: 1 addition & 1 deletion config/locales/simple_form.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fr:
allow_signup: Autoriser les utilisateurs à s'inscrire à votre référentiel
cache_api: Active le cache pour les points de terminaison d'API. Expérimental
contact_email: Email destinataire des messages envoyés via le formulaire de contact
contact_email_to: Adresse e-mail qui doit recevoir les e-mails de contact
contact_email_to: Email destinataire des messages envoyés via le formulaire de contact
doi_reader: Afficher la possibilité de lire à partir de Datacite pour remplir les enregistrements. WIP ne pas utiliser
doi_writer: Rédigez des DOI pour les enregistrements. WIP ne pas utiliser
email_format: Définissez une liste de domaines de messagerie autorisés à s'inscrire à ce référentiel, par exemple (@ubiquitypress.com @gmail.com). Laissez un seul espace entre chaque domaine.
Expand Down
2 changes: 1 addition & 1 deletion config/locales/simple_form.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ it:
allow_signup: Consenti agli utenti di registrarsi al tuo repository
cache_api: Attiva la cache per gli endpoint API. Sperimentale
contact_email: Email destinatario dei messaggi inviati tramite il modulo di contatto
contact_email_to: Indirizzo e-mail che dovrebbe ricevere le e-mail di contatto
contact_email_to: Email destinatario dei messaggi inviati tramite il modulo di contatto
doi_reader: Mostra la capacità di leggere da Datacite per popolare i record. WIP non utilizzare
doi_writer: Scrivi DOI per i record. WIP non utilizzare
email_format: Impostare un elenco di domini di posta elettronica a cui è consentito registrarsi a questo repository, ad esempio (@ubiquitypress.com @gmail.com). Lascia un singolo spazio tra ogni dominio.
Expand Down
2 changes: 1 addition & 1 deletion config/locales/simple_form.pt-.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pt-:
allow_signup: Permitir que os usuários se inscrevam em seu repositório
cache_api: Ativa o cache para terminais de API. Experimental
contact_email: Destinatário de e-mail de mensagens enviadas por meio do formulário de contato
contact_email_to: Endereço de e-mail que deve receber e-mails de contato
contact_email_to: Destinatário de e-mail de mensagens enviadas por meio do formulário de contato
doi_reader: Mostrar capacidade de ler do Datacite para preencher registros. WIP não use
doi_writer: Escreva DOIs para registros. WIP não use
email_format: Defina uma lista de domínios de e-mail que podem se inscrever neste repositório, por exemplo (@ubiquitypress.com @gmail.com). Deixe um único espaço entre cada domínio.
Expand Down
2 changes: 1 addition & 1 deletion config/locales/simple_form.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pt-BR:
allow_signup: Permitir que os usuários se inscrevam em seu repositório
cache_api: Ativa o cache para terminais de API. Experimental
contact_email: Destinatário de e-mail de mensagens enviadas por meio do formulário de contato
contact_email_to: Endereço de e-mail que deve receber e-mails de contato
contact_email_to: Destinatário de e-mail de mensagens enviadas por meio do formulário de contato
doi_reader: Mostrar capacidade de ler do Datacite para preencher registros. WIP não use
doi_writer: Escreva DOIs para registros. WIP não use
email_format: Defina uma lista de domínios de e-mail que podem se inscrever neste repositório, por exemplo (@ubiquitypress.com @gmail.com). Deixe um único espaço entre cada domínio.
Expand Down
2 changes: 1 addition & 1 deletion config/locales/simple_form.zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ zh:
allow_signup: 允许用户注册到您的存储库
cache_api: 为 API 端点打开缓存。实验性的
contact_email: 通过联系表发送的邮件的电子邮件收件人
contact_email_to: 应接收联系电子邮件的电子邮件地址
contact_email_to: 通过联系表发送的邮件的电子邮件收件人
doi_reader: 显示从 Datacite 读取数据以填充记录的能力。 WIP 不使用
doi_writer: 为记录写 DOI。 WIP 不使用
email_format: 设置允许注册此存储库的电子邮件域列表,例如 (@ubiquitypress.com @gmail.com)。在每个域之间留一个空格。
Expand Down
4 changes: 4 additions & 0 deletions config/locales/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ zh:
manage_groups: 管理组
system_status: 系统状态
users:
activate:
confirmation: 您确定要激活用户“%{user}”吗?
failure: 无法激活用户“%{user}”。
success: 用户“%{user}”已成功激活。
destroy:
confirmation: 您确定要删除用户“%{user}”吗?这一行动是不可逆转的。
failure: 无法删除用户“%{user}”。
Expand Down
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@
namespace :admin do
resource :account, only: [:edit, :update]
resource :work_types, only: [:edit, :update]
resources :users, only: [:destroy]
resources :users, only: [:index, :destroy] do
post 'activate', on: :member
end
resources :groups do
member do
get :remove
Expand Down
2 changes: 2 additions & 0 deletions ops/staging-deploy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ extraEnvVars: &envVars
value: "true"
- name: HYKU_ROOT_HOST
value: atla-hyku.notch8.cloud
- name: HYKU_USER_DEFAULT_PASSWORD
value: password
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

along with this there should be similar changes in the ops/production-deploy.tmpl.yaml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kirkkwang thanks! added this

- name: NEGATIVE_CAPTCHA_SECRET
value: $NEGATIVE_CAPTCHA_SECRET
- name: SMTP_ADDRESS
Expand Down
22 changes: 20 additions & 2 deletions spec/controllers/admin/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
end

context 'as an admin user' do
let(:user) { FactoryBot.create(:user) }

before do
sign_in create(:admin)
end

describe 'DELETE #destroy' do
subject { User.find_by(id: user.id) }

let(:user) { FactoryBot.create(:user) }

before do
delete :destroy, params: { id: user.to_param }
end
Expand All @@ -38,5 +38,23 @@
expect(flash[:notice]).to eq "User \"#{user.email}\" has been successfully deleted."
end
end
describe 'POST #activate' do
let(:user) { User.invite!(email: '[email protected]', skip_invitation: true) }

before do
post :activate, params: { id: user.id }
end

it 'accepts the invitation for the user' do
expect(user).not_to be_accepted_or_not_invited
user.reload
expect(user).to be_accepted_or_not_invited
end

it 'redirects to the admin users path with a success notice' do
expect(response).to redirect_to(admin_users_path)
expect(flash[:notice]).to eq "User \"#{user.email}\" has been successfully activated."
end
end
end
end
Empty file removed tmp/pids/.keep
Empty file.
Loading