GRN2-xx: Fixed issue with recording row and added small fix to roles migration (Fixed #717, #718) (#719)

* Fixed issue with recording row and added small fix to roles migration

* Fixed issue with edit user avatar

* Small bug fixes for user settings

* Added autofocus on name field when joining

* Added extra check for admin password check

* Rubocop fixes
This commit is contained in:
farhatahmad 2019-08-01 16:53:26 -04:00 committed by Jesus Federico
parent 4fc1714db8
commit 60f5cd5c81
7 changed files with 99 additions and 92 deletions

View File

@ -18,16 +18,6 @@ $(document).on('turbolinks:load', function(){
var controller = $("body").data('controller');
var action = $("body").data('action');
if ((controller == "admins" && action == "edit_user") || (controller == "users" && action == "edit")) {
$(".setting-btn").click(function(data){
var url = $("body").data("relative-root")
if (!url.endsWith("/")) {
url += "/"
}
url += "admins?setting=" + data.target.id
window.location.href = url
})
// Clear the role when the user clicks the x
$(".clear-role").click(clearRole)

View File

@ -137,8 +137,8 @@ class ApplicationController < ActionController::Base
# Checks to make sure that the admin has changed his password from the default
def check_admin_password
if current_user&.has_role?(:admin) && current_user&.greenlight_account? &&
current_user&.authenticate(Rails.configuration.admin_password_default)
if current_user&.has_role?(:admin) && current_user.email == "admin@example.com" &&
current_user&.greenlight_account? && current_user&.authenticate(Rails.configuration.admin_password_default)
flash.now[:alert] = I18n.t("default_admin",
edit_link: edit_user_path(user_uid: current_user.uid) + "?setting=password").html_safe
@ -157,28 +157,7 @@ class ApplicationController < ActionController::Base
else
@user_domain = parse_user_domain(request.host)
# Checks to see if the user exists
begin
retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
rescue => e
# Use the default site settings
@user_domain = "greenlight"
if e.message.eql? "No user with that id exists"
render "errors/greenlight_error", locals: { message: I18n.t("errors.not_found.user_not_found.message"),
help: I18n.t("errors.not_found.user_not_found.help") }
elsif e.message.eql? "Provider not included."
render "errors/greenlight_error", locals: { message: I18n.t("errors.not_found.user_missing.message"),
help: I18n.t("errors.not_found.user_missing.help") }
elsif e.message.eql? "That user has no configured provider."
render "errors/greenlight_error", locals: { status_code: 501,
message: I18n.t("errors.no_provider.message"),
help: I18n.t("errors.no_provider.help") }
else
render "errors/greenlight_error", locals: { status_code: 500, message: I18n.t("errors.internal.message"),
help: I18n.t("errors.internal.help"), display_back: true }
end
end
check_provider_exists
end
end
helper_method :set_user_domain
@ -199,4 +178,38 @@ class ApplicationController < ActionController::Base
def handle_bigbluebutton_error
render "errors/bigbluebutton_error"
end
private
def check_provider_exists
# Checks to see if the user exists
begin
# Check if the session has already checked that the user exists
# and return true if they did for this domain
return if session[:provider_exists] == @user_domain
retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
# Add a session variable if the provider exists
session[:provider_exists] = @user_domain
rescue => e
# Use the default site settings
@user_domain = "greenlight"
if e.message.eql? "No user with that id exists"
render "errors/greenlight_error", locals: { message: I18n.t("errors.not_found.user_not_found.message"),
help: I18n.t("errors.not_found.user_not_found.help") }
elsif e.message.eql? "Provider not included."
render "errors/greenlight_error", locals: { message: I18n.t("errors.not_found.user_missing.message"),
help: I18n.t("errors.not_found.user_missing.help") }
elsif e.message.eql? "That user has no configured provider."
render "errors/greenlight_error", locals: { status_code: 501,
message: I18n.t("errors.no_provider.message"),
help: I18n.t("errors.no_provider.help") }
else
render "errors/greenlight_error", locals: { status_code: 500, message: I18n.t("errors.internal.message"),
help: I18n.t("errors.internal.help"), display_back: true }
end
end
end
end

View File

@ -24,7 +24,8 @@
required: true,
class: "form-control join-form",
placeholder: t("room.enter_the_access_code"),
value: "" %>
value: "" ,
autofocus: true %>
<%= f.submit t("room.login"), class: "btn btn-primary btn-sm col-sm-3 form-control join-form" %>
</div>
<% end %>
@ -39,7 +40,9 @@
class: "form-control join-form",
placeholder: t("enter_your_name"),
value: "#{@name}",
readonly: !current_user.nil? %>
readonly: !current_user.nil?,
autofocus: true
%>
<%= f.submit (!@is_running && @anyone_can_start)? t("room.start") : t("room.join"), class: "btn btn-primary btn-sm col-sm-3 form-control join-form" %>
</div>
<% end %>

View File

@ -32,7 +32,7 @@
<td class="overflow-hidden">
<% p = recording[:playbacks].find do |p| p.key?(:preview) end %>
<% if p %>
<% p[:preview][:images][:image].each do |img| %>
<% safe_recording_images(p[:preview][:images][:image]).each do |img| %>
<%= image_tag(img[:content].strip, class: "thumbnail px-2") %>
<% end %>
<% end %>

View File

@ -27,7 +27,7 @@
<div class="col-6">
<%= f.label t("email"), class: "form-label" %>
<div class="input-icon">
<%= f.text_field :email, class: "form-control #{form_is_invalid?(@user, :email)}", placeholder: t("email"), readonly: !current_user.greenlight_account? %>
<%= f.text_field :email, class: "form-control #{form_is_invalid?(@user, :email)}", placeholder: t("email"), readonly: !@user.greenlight_account? %>
</div>
</div>
</div>
@ -63,10 +63,10 @@
<%= f.label t("settings.account.image"), class: "form-label mt-5" %>
<div class="row">
<div class="col-2">
<% if current_user.image.blank? %>
<span class="avatar avatar-xxl mr-5 mt-2"><%= current_user.name.first %></span>
<% if @user.image.blank? %>
<span class="avatar avatar-xxl mr-5 mt-2"><%= @user.name.first %></span>
<% else %>
<span class="avatar avatar-xxl mr-5 mt-2" style="background-image: url(<%= current_user.image %>)"></span>
<span class="avatar avatar-xxl mr-5 mt-2" style="background-image: url(<%= @user.image %>)"></span>
<% end %>
</div>
<div class="col-10 mt-5">

View File

@ -21,10 +21,6 @@
</div>
</div>
<% unless (defined?(admin_view)).nil? %>
<%= render "shared/admin_settings/#{setting_id}" %>
<% else %>
<%= render "shared/settings/#{setting_id}" %>
<% end %>
</div>
<% end %>

View File

@ -52,7 +52,12 @@ class AddCustomRoles < ActiveRecord::Migration[5.2]
new_assignments = []
old_assignments.each do |assignment|
begin
user = User.find(assignment["user_id"])
rescue
next
end
new_assignment = { "user_id" => assignment["user_id"] }
if assignment["role_id"] == super_admin_id
new_assignment["new_role_id"] = generate_scoped_role(user, "super_admin")