FEATURE: delete all accounts from this IP in the IP lookup modal
This commit is contained in:
parent
5f4e4de02a
commit
b8d806ee07
|
@ -39,6 +39,22 @@ export default Ember.Component.extend({
|
|||
|
||||
hide: function () {
|
||||
this.set("show", false);
|
||||
},
|
||||
|
||||
deleteAllOtherAccounts: function() {
|
||||
var self = this;
|
||||
this.setProperties({ other_accounts: null, otherAccountsLoading: true });
|
||||
|
||||
Discourse.ajax("/admin/users/delete-others-with-same-ip.json", {
|
||||
type: "DELETE",
|
||||
data: {
|
||||
"ip": this.get("ip"),
|
||||
"exclude": this.get("user_id"),
|
||||
"order": "trust_level DESC"
|
||||
}
|
||||
}).then(function() {
|
||||
self.send("lookup");
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{{#if ip}}
|
||||
<button class="btn" {{action "lookup"}}>
|
||||
<span class="fa fa-globe"></span> {{i18n admin.user.ip_lookup}}
|
||||
{{fa-icon "globe"}}{{i18n admin.user.ip_lookup}}
|
||||
</button>
|
||||
{{/if}}
|
||||
{{#if show}}
|
||||
<div class="location-box">
|
||||
<a class="close" {{action "hide"}}>{{fa-icon "times"}}</a>
|
||||
<a class="close pull-right" {{action "hide"}}>{{fa-icon "times"}}</a>
|
||||
<h4>{{i18n ip_lookup.title}}</h4>
|
||||
<dl>
|
||||
{{#if location}}
|
||||
|
@ -37,10 +37,18 @@
|
|||
{{loading-spinner size="small"}}
|
||||
{{/if}}
|
||||
|
||||
<dt>{{i18n ip_lookup.other_accounts}} <strong>{{other_accounts.length}}</strong></dt>
|
||||
<dd class="other-accounts">
|
||||
{{#loading-spinner size="small" condition=otherAccountsLoading}}
|
||||
{{#if other_accounts}}
|
||||
<dt>
|
||||
{{i18n ip_lookup.other_accounts}}
|
||||
<strong>{{other_accounts.length}}</strong>
|
||||
{{#if other_accounts.length}}
|
||||
<button class="btn btn-danger pull-right" {{action "deleteAllOtherAccounts"}}>
|
||||
{{fa-icon "trash-o"}}{{i18n ip_lookup.delete_all}}
|
||||
</button>
|
||||
{{/if}}
|
||||
</dt>
|
||||
{{#loading-spinner size="small" condition=otherAccountsLoading}}
|
||||
{{#if other_accounts.length}}
|
||||
<dd class="other-accounts">
|
||||
<table class="table table-condensed table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -63,11 +71,9 @@
|
|||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{else}}
|
||||
{{i18n ip_lookup.no_other_accounts}}
|
||||
{{/if}}
|
||||
{{/loading-spinner}}
|
||||
<dd>
|
||||
</dd>
|
||||
{{/if}}
|
||||
{{/loading-spinner}}
|
||||
</dl>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
|
@ -82,16 +82,15 @@ td.flaggers td {
|
|||
margin-top: -2px;
|
||||
background-color: $secondary;
|
||||
padding: 12px 12px 5px;
|
||||
.close {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.other-accounts {
|
||||
margin: 0;
|
||||
margin: 5px 0 0;
|
||||
max-height: 200px;
|
||||
overflow: auto;
|
||||
width: 455px;
|
||||
ul { margin: 0; }
|
||||
li { list-style: none; }
|
||||
tr td:first-of-type { width: 130px; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,10 +264,7 @@ class Admin::UsersController < Admin::AdminController
|
|||
end
|
||||
|
||||
def sync_sso
|
||||
unless SiteSetting.enable_sso
|
||||
render nothing: true, status: 404
|
||||
return
|
||||
end
|
||||
return render nothing: true, status: 404 unless SiteSetting.enable_sso
|
||||
|
||||
sso = DiscourseSingleSignOn.parse("sso=#{params[:sso]}&sig=#{params[:sig]}")
|
||||
user = sso.lookup_or_create_user
|
||||
|
@ -275,6 +272,21 @@ class Admin::UsersController < Admin::AdminController
|
|||
render_serialized(user, AdminDetailedUserSerializer, root: false)
|
||||
end
|
||||
|
||||
def delete_other_accounts_with_same_ip
|
||||
params.require(:ip)
|
||||
params.require(:exclude)
|
||||
params.require(:order)
|
||||
|
||||
user_destroyer = UserDestroyer.new(current_user)
|
||||
options = { delete_posts: true, block_email: true, block_urls: true, block_ip: true, delete_as_spammer: true }
|
||||
|
||||
AdminUserIndexQuery.new(params).find_users.each do |user|
|
||||
user_destroyer.destroy(user, options) rescue nil
|
||||
end
|
||||
|
||||
render json: success_json
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def fetch_user
|
||||
|
|
|
@ -279,7 +279,7 @@ en:
|
|||
organisation: Organization
|
||||
phone: Phone
|
||||
other_accounts: "Other accounts with this IP address:"
|
||||
no_other_accounts: (none)
|
||||
delete_all: "Delete all"
|
||||
username: "username"
|
||||
trust_level: "TL"
|
||||
read_time: "read time"
|
||||
|
|
|
@ -52,6 +52,7 @@ Discourse::Application.routes.draw do
|
|||
collection do
|
||||
get "list/:query" => "users#index"
|
||||
get "ip-info" => "users#ip_info"
|
||||
delete "delete-others-with-same-ip" => "users#delete_other_accounts_with_same_ip"
|
||||
put "approve-bulk" => "users#approve_bulk"
|
||||
delete "reject-bulk" => "users#reject_bulk"
|
||||
end
|
||||
|
|
|
@ -414,6 +414,19 @@ describe Admin::UsersController do
|
|||
|
||||
end
|
||||
|
||||
context "delete_other_accounts_with_same_ip" do
|
||||
|
||||
it "works" do
|
||||
Fabricate(:user, ip_address: "42.42.42.42")
|
||||
Fabricate(:user, ip_address: "42.42.42.42")
|
||||
|
||||
UserDestroyer.any_instance.expects(:destroy).twice
|
||||
|
||||
xhr :delete, :delete_other_accounts_with_same_ip, ip: "42.42.42.42", exclude: -1, order: "trust_level DESC"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
it 'can sync up sso' do
|
||||
|
|
Loading…
Reference in New Issue