Skip to content
Snippets Groups Projects
Commit 3f6d5d9a authored by pabois's avatar pabois
Browse files

unlock user

parent 951fbf87
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,16 @@ class Admin::UsersController < Admin::ApplicationController
end
end
def unlock
if @user.access_locked? || @user.max_login_attempts?
@user.unlock_access!
@user.unlock_mfa!
redirect_back(fallback_location: [:admin, @user], notice: 'User account was successfully unlocked.')
else
redirect_back(fallback_location: [:admin, @user], alert: 'User account was not locked.')
end
end
def destroy
@user.destroy
redirect_to admin_users_url, notice: "User was successfully destroyed."
......
<% if @user.max_login_attempts? %>
<div class="alert alert-danger">
This user account is currently <i>locked</i> due to too many MFA attempts.
<%= link_to 'Unlock it now!', unlock_admin_user_path(@user), method: :patch, class: 'alert-link' if can?(:update, @user) %>
</div>
<% end %>
<% if @user.access_locked? %>
<div class="alert alert-danger">
This user account is currently <i>locked</i>.
<% if [:time, :both].include?(Rails.configuration.devise.unlock_strategy) %>
<% distance = distance_of_time_in_words(@user.locked_at + Rails.configuration.devise.unlock_in - Time.now.utc) %>
<%= "It will unlock automatically in <i>#{distance}</i>.".html_safe %>
<% end %>
<%= link_to 'Unlock it now!', unlock_admin_user_path(@user), method: :patch, class: 'alert-link' if can?(:update, @user) %>
</div>
<% end %>
<% content_for :title, @user %>
<%= render 'lock' %>
<%= render 'form', user: @user %>
<% content_for :title, @user %>
<%= render 'lock' %>
<p>
<strong>First name:</strong>
<%= @user.first_name %>
......
......@@ -10,7 +10,11 @@ Rails.application.routes.draw do
resources :languages
namespace :admin do
resources :users
resources :users do
member do
patch 'unlock' => 'users#unlock'
end
end
draw 'education'
draw 'research'
draw 'communication'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment