mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 13:13:22 +08:00
fix bug with changing user own role from admin to normal user
This commit is contained in:
parent
3d9323c8d7
commit
27c661d7c4
2 changed files with 16 additions and 3 deletions
|
@ -147,8 +147,15 @@ function initUpdateRoles() {
|
|||
"ajax:success",
|
||||
"[data-id='update-role-form']",
|
||||
function (e, data, status, xhr) {
|
||||
// Reload the whole table
|
||||
usersDatatable.ajax.reload();
|
||||
// If user does'n have permission to view the team anymore
|
||||
// he/she is redirected to teams page
|
||||
if (data.new_path) {
|
||||
location.replace(data.new_path);
|
||||
}
|
||||
else {
|
||||
// Reload the whole table
|
||||
usersDatatable.ajax.reload();
|
||||
}
|
||||
}
|
||||
)
|
||||
.on(
|
||||
|
|
|
@ -16,9 +16,15 @@ module Users
|
|||
def update
|
||||
respond_to do |format|
|
||||
if @user_t.update(update_params)
|
||||
# If user is administrator of team,
|
||||
# and he/she changes his/her role
|
||||
# he/she should be redirected to teams page
|
||||
new_path = teams_path if @user_t.user == @current_user &&
|
||||
@user_t.role != 'admin'
|
||||
format.json do
|
||||
render json: {
|
||||
status: :ok
|
||||
status: :ok,
|
||||
new_path: new_path
|
||||
}
|
||||
end
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue