admins: user reset login times action

dev_auth
p31729568 5 years ago
parent 932779e882
commit 46a837d4d0

@ -80,6 +80,21 @@ $(document).on('turbolinks:load', function(){
}) })
}); });
// reset user login times
$('.users-list-container').on('click', '.reset-login-times-action', function(){
var $action = $(this);
var userId = $action.data('id');
$.ajax({
url: '/admins/users/' + userId + '/reset_login_times',
method: 'POST',
dataType: 'json',
success: function() {
showSuccessNotify();
}
});
});
// ***************** reward grade modal ***************** // ***************** reward grade modal *****************
var $rewardGradeModal = $('.admin-users-reward-grade-modal'); var $rewardGradeModal = $('.admin-users-reward-grade-modal');
var $form = $rewardGradeModal.find('form.admin-users-reward-grade-form'); var $form = $rewardGradeModal.find('form.admin-users-reward-grade-form');

@ -52,6 +52,12 @@ class Admins::UsersController < Admins::BaseController
render_ok(grade: user.grade) render_ok(grade: user.grade)
end end
def reset_login_times
User.find(params[:id]).reset_login_times!
render_ok
end
private private
def update_params def update_params

@ -32,6 +32,7 @@ class LimitForbidControl::Base
# 锁定 # 锁定
if value >= allow_times.to_i if value >= allow_times.to_i
Rails.logger.info("[LimitForbidControl] Lock #{cache_key}")
Rails.cache.write(forbid_cache_key, true, expires_in: forbid_expires) Rails.cache.write(forbid_cache_key, true, expires_in: forbid_expires)
Rails.cache.delete(cache_key) Rails.cache.delete(cache_key)
else else
@ -40,6 +41,7 @@ class LimitForbidControl::Base
end end
def clear def clear
Rails.logger.info("[LimitForbidControl] Clear #{cache_key}")
Rails.cache.delete(forbid_cache_key) Rails.cache.delete(forbid_cache_key)
Rails.cache.delete(cache_key) Rails.cache.delete(cache_key)
end end

@ -660,6 +660,10 @@ class User < ApplicationRecord
end end
end end
def reset_login_times!
LimitForbidControl::UserLogin.new(self).clear
end
protected protected
def validate_password_length def validate_password_length
# 管理员的初始密码是5位 # 管理员的初始密码是5位

@ -2,15 +2,15 @@
<thead class="thead-light"> <thead class="thead-light">
<tr> <tr>
<th width="10%" class="text-left">真实姓名</th> <th width="10%" class="text-left">真实姓名</th>
<th width="16%">邮件地址</th> <th width="15%">邮件地址</th>
<th width="10%">手机号码</th> <th width="10%">手机号码</th>
<th width="14%">单位</th> <th width="14%">单位</th>
<th width="8%">角色</th> <th width="7%">角色</th>
<th width="10%"><%= sort_tag('创建于', name: 'created_on', path: admins_users_path) %></th> <th width="10%"><%= sort_tag('创建于', name: 'created_on', path: admins_users_path) %></th>
<th width="10%"><%= sort_tag('最后登录', name: 'last_login_on', path: admins_users_path) %></th> <th width="10%"><%= sort_tag('最后登录', name: 'last_login_on', path: admins_users_path) %></th>
<th width="6%"><%= sort_tag('经验值', name: 'experience', path: admins_users_path) %></th> <th width="6%"><%= sort_tag('经验值', name: 'experience', path: admins_users_path) %></th>
<th width="6%"><%= sort_tag('金币', name: 'grade', path: admins_users_path) %></th> <th width="6%"><%= sort_tag('金币', name: 'grade', path: admins_users_path) %></th>
<th width="12%">操作</th> <th width="14%">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -33,8 +33,6 @@
<td class="action-container"> <td class="action-container">
<%= link_to '编辑', edit_admins_user_path(user), class: 'action' %> <%= link_to '编辑', edit_admins_user_path(user), class: 'action' %>
<%= javascript_void_link('奖励', class: 'action reward-grade-action', data: { toggle: 'modal', target: '.admin-users-reward-grade-modal', id: user.id }) %>
<%= javascript_void_link '解锁', class: 'action unlock-action', data: { id: user.id }, style: user.locked? ? '' : 'display: none;' %> <%= javascript_void_link '解锁', class: 'action unlock-action', data: { id: user.id }, style: user.locked? ? '' : 'display: none;' %>
<% if user.registered? %> <% if user.registered? %>
@ -45,7 +43,14 @@
<%= javascript_void_link '加锁', class: 'action lock-action', data: { id: user.id }, style: user.locked? || user.registered? ? 'display: none;' : '' %> <%= javascript_void_link '加锁', class: 'action lock-action', data: { id: user.id }, style: user.locked? || user.registered? ? 'display: none;' : '' %>
<% end %> <% end %>
<%= delete_link '删除', admins_user_path(user, element: ".user-item-#{user.id}"), class: 'delete-user-action' %> <%= javascript_void_link('更多', class: 'action dropdown-toggle', 'data-toggle': 'dropdown', 'aria-haspopup': true, 'aria-expanded': false) %>
<div class="dropdown-menu more-action-dropdown">
<%= javascript_void_link('奖励', class: 'dropdown-item reward-grade-action', data: { toggle: 'modal', target: '.admin-users-reward-grade-modal', id: user.id }) %>
<%= javascript_void_link '恢复禁密账号', class: 'dropdown-item reset-login-times-action', data: { id: user.id } %>
<%= delete_link '删除', admins_user_path(user, element: ".user-item-#{user.id}"), class: 'dropdown-item delete-user-action' %>
</div>
</td> </td>
</tr> </tr>
<% end %> <% end %>

@ -906,6 +906,7 @@ Rails.application.routes.draw do
post :lock post :lock
post :unlock post :unlock
post :active post :active
post :reset_login_times
end end
end end
resource :import_users, only: [:create] resource :import_users, only: [:create]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -138762,6 +138762,21 @@ $(document).on('turbolinks:load', function(){
}) })
}); });
// reset user login times
$('.users-list-container').on('click', '.reset-login-times-action', function(){
var $action = $(this);
var userId = $action.data('id');
$.ajax({
url: '/admins/users/' + userId + '/reset_login_times',
method: 'POST',
dataType: 'json',
success: function() {
showSuccessNotify();
}
});
});
// ***************** reward grade modal ***************** // ***************** reward grade modal *****************
var $rewardGradeModal = $('.admin-users-reward-grade-modal'); var $rewardGradeModal = $('.admin-users-reward-grade-modal');
var $form = $rewardGradeModal.find('form.admin-users-reward-grade-form'); var $form = $rewardGradeModal.find('form.admin-users-reward-grade-form');

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save