Merge pull request #556 from mlorb/ml_sci_1174

Fix bug with changing user own role from admin to normal user [SCI-1174]
This commit is contained in:
mlorb 2017-04-13 14:33:58 +02:00 committed by GitHub
commit ddc0e86c92
2 changed files with 16 additions and 3 deletions

View file

@ -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(

View file

@ -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