From 4f70c9a8e539d08a0280bc3be076eabcf9d65a67 Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 8 Jun 2018 14:44:08 -0400 Subject: [PATCH] validate passwords and fix home --- app/assets/stylesheets/application.scss | 13 +++++-- app/controllers/application_controller.rb | 6 ++++ app/controllers/rooms_controller.rb | 4 +-- app/controllers/users_controller.rb | 10 +++--- app/models/user.rb | 9 +++-- app/views/layouts/application.html.erb | 5 +-- app/views/main/index.html.erb | 41 +++++------------------ app/views/users/new.html.erb | 33 +++++++++--------- config/routes.rb | 2 +- 9 files changed, 54 insertions(+), 69 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index a0347fcf..1bf2c6ce 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -57,6 +57,8 @@ a { } .room-section { + position: relative; + height: 45%; background-color: $background-color; } @@ -96,8 +98,9 @@ iframe{ } .feature-stamp { - width: 100px; - height: 100px; + width: 7vw; + height: 7vw; + font-size: 1vw; } html, body { @@ -106,12 +109,16 @@ html, body { background-color: white; } +.resp-header { + font-size: 3.3vw; +} + .font-weight-400 { font-weight: 400; } .wrapper { - min-height: calc(100% - #{$footer-height}); + height: calc(100% - #{$footer-height}); position: relative; } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 44971d21..e9d6f23b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -42,6 +42,12 @@ class ApplicationController < ActionController::Base @room.meeting.join_path(current_user.name, opts) end helper_method :owner_meeting_url + + # Determines if a form field needs the is-invalid class. + def form_is_invalid?(obj, key) + 'is-invalid' if !obj.errors.messages[key].empty? + end + helper_method :form_is_invalid? # Default, unconfigured meeting options. def default_meeting_options diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index 254e2783..6a22bfd0 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -1,9 +1,7 @@ class RoomsController < ApplicationController before_action :find_room, except: :create - - #before_action :verify_room_ownership - #skip_before_action :verify_room_ownership, only: [:create, :show, :join, :wait] + before_action :verify_room_ownership, only: [:start, :destroy, :home] # POST /r def create diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 95138c44..a3c17818 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -5,14 +5,14 @@ class UsersController < ApplicationController # POST /users def create - user = User.new(user_params) - user.provider = "greenlight" + @user = User.new(user_params) + @user.provider = "greenlight" - if user.save - login(user) + if @user.save + login(@user) else # Handle error on user creation. - + render :new end end diff --git a/app/models/user.rb b/app/models/user.rb index ac1af10b..1e6c24fd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -12,10 +12,9 @@ class User < ApplicationRecord uniqueness: { case_sensitive: false }, format: {with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i } - validates :password, length: { minimum: 6 }, allow_nil: true + validates :password, length: { minimum: 6 }, presence: true, confirmation: true, if: :greenlight_account? - # We don't want to run the validations because they require a user - # to have a password. Users who authenticate via omniauth won't. + # We don't want to require password validations on all accounts. has_secure_password(validations: false) class << self @@ -90,6 +89,10 @@ class User < ApplicationRecord name.split(' ').first end + def greenlight_account? + provider == "greenlight" + end + private # Initializes a room for the user and assign a BigBlueButton user id. diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c1209583..cc1f00d9 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -8,10 +8,7 @@ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> - - +
diff --git a/app/views/main/index.html.erb b/app/views/main/index.html.erb index f382ad7b..b5992157 100644 --- a/app/views/main/index.html.erb +++ b/app/views/main/index.html.erb @@ -1,37 +1,14 @@ -
-
+
+
+
+

Welcome to BigBlueButton.

+

A simple front end for your BigBlueButton Open Source Web Conferencing Server.

-

Welcome to BigBlueButton.

-

A simple front end for your BigBlueButton Open Source Web Conferencing Server.

- - <%= link_to "https://www.youtube.com/watch?v=yGX3JCv7OVM&feature=youtu.be", class: "p-3", target: "_blank" do %> -

Watch a tutorial on using Greenlight

- <% end %> + <%= link_to "https://www.youtube.com/watch?v=yGX3JCv7OVM&feature=youtu.be", class: "p-3", target: "_blank" do %> +

Watch a tutorial on using Greenlight

+ <% end %> +
<%= render "shared/features" %> - - diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index a892e4fb..56620103 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -6,29 +6,26 @@

Create an Account

- <%= form_for @user, method: :post do |f| %> + <%= form_for @user, url: create_user_path, method: :post do |f| %>
<%= f.label "Fullname", class: "form-label" %> -
- - - - <%= f.text_field :name, class: "form-control", placeholder: "Fullname" %> -
-
+ <%= f.text_field :name, class: "form-control #{form_is_invalid?(@user, :name)}", placeholder: "Fullname" %> +
<%= @user.errors.full_messages_for(:name).first %>
+
+
<%= f.label "Email", class: "form-label" %> -
- - - - <%= f.text_field :email, class: "form-control", placeholder: "Email" %> -
-
+ <%= f.text_field :email, class: "form-control #{form_is_invalid?(@user, :email)}", placeholder: "Email" %> +
<%= @user.errors.full_messages_for(:email).first %>
+
+
<%= f.label "Password", class: "form-label" %> - <%= f.password_field :password, class: "form-control", placeholder: "Password" %> -
+ <%= f.password_field :password, class: "form-control #{form_is_invalid?(@user, :password)}", placeholder: "Password" %> +
<%= @user.errors.full_messages_for(:password).first %>
+
+
<%= f.label "Password Confirmation", class: "form-label" %> - <%= f.password_field :password, class: "form-control", placeholder: "Password Confirmation" %> + <%= f.password_field :password_confirmation, class: "form-control #{form_is_invalid?(@user, :password_confirmation)}", placeholder: "Password Confirmation" %> +
<%= @user.errors.full_messages_for(:password_confirmation).first %>