forked from External/greenlight
GRN2-268: Redirecting user back to page they came from in Manage Users (#950)
* GRN2-268: Redirecting user back to page they come from in Manage Users * re-factoring
This commit is contained in:
parent
68b231dbdb
commit
01c93b1f67
|
@ -75,20 +75,23 @@ class AdminsController < ApplicationController
|
|||
|
||||
# GET /admins/edit/:user_uid
|
||||
def edit_user
|
||||
session[:prev_url] = request.referer if request.referer.present?
|
||||
end
|
||||
|
||||
# POST /admins/ban/:user_uid
|
||||
def ban_user
|
||||
@user.roles = []
|
||||
@user.add_role :denied
|
||||
redirect_to admins_path, flash: { success: I18n.t("administrator.flash.banned") }
|
||||
|
||||
redirect_back fallback_location: admins_path, flash: { success: I18n.t("administrator.flash.banned") }
|
||||
end
|
||||
|
||||
# POST /admins/unban/:user_uid
|
||||
def unban_user
|
||||
@user.remove_role :denied
|
||||
@user.add_role :user
|
||||
redirect_to admins_path, flash: { success: I18n.t("administrator.flash.unbanned") }
|
||||
|
||||
redirect_back fallback_location: admins_path, flash: { success: I18n.t("administrator.flash.unbanned") }
|
||||
end
|
||||
|
||||
# POST /admins/approve/:user_uid
|
||||
|
@ -97,7 +100,7 @@ class AdminsController < ApplicationController
|
|||
|
||||
send_user_approved_email(@user)
|
||||
|
||||
redirect_to admins_path, flash: { success: I18n.t("administrator.flash.approved") }
|
||||
redirect_back fallback_location: admins_path, flash: { success: I18n.t("administrator.flash.approved") }
|
||||
end
|
||||
|
||||
# POST /admins/approve/:user_uid
|
||||
|
@ -106,7 +109,7 @@ class AdminsController < ApplicationController
|
|||
@user.undelete!
|
||||
@user.rooms.deleted.each(&:undelete!)
|
||||
|
||||
redirect_to admins_path, flash: { success: I18n.t("administrator.flash.restored") }
|
||||
redirect_back fallback_location: admins_path, flash: { success: I18n.t("administrator.flash.restored") }
|
||||
end
|
||||
|
||||
# POST /admins/invite
|
||||
|
@ -128,7 +131,14 @@ class AdminsController < ApplicationController
|
|||
|
||||
send_password_reset_email(@user)
|
||||
|
||||
redirect_to admins_path, flash: { success: I18n.t("administrator.flash.reset_password") }
|
||||
if session[:prev_url].present?
|
||||
redirect_path = session[:prev_url]
|
||||
session.delete(:prev_url)
|
||||
else
|
||||
redirect_path = admins_path
|
||||
end
|
||||
|
||||
redirect_to redirect_path, flash: { success: I18n.t("administrator.flash.reset_password") }
|
||||
end
|
||||
# SITE SETTINGS
|
||||
|
||||
|
|
|
@ -80,7 +80,14 @@ class UsersController < ApplicationController
|
|||
# PATCH /u/:user_uid/edit
|
||||
def update
|
||||
profile = params[:setting] == "password" ? change_password_path(@user) : edit_user_path(@user)
|
||||
redirect_path = current_user.admin_of?(@user) ? admins_path : profile
|
||||
if session[:prev_url].present?
|
||||
path = session[:prev_url]
|
||||
session.delete(:prev_url)
|
||||
else
|
||||
path = admins_path
|
||||
end
|
||||
|
||||
redirect_path = current_user.admin_of?(@user) ? path : profile
|
||||
|
||||
if params[:setting] == "password"
|
||||
# Update the users password.
|
||||
|
|
Loading…
Reference in New Issue