validate passwords and fix home

This commit is contained in:
Josh 2018-06-08 14:44:08 -04:00
parent 520c489e62
commit 4f70c9a8e5
9 changed files with 54 additions and 69 deletions

View File

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

View File

@ -43,6 +43,12 @@ class ApplicationController < ActionController::Base
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
{

View File

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

View File

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

View File

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

View File

@ -8,10 +8,7 @@
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body class="app-background" data-controller="<%= params[:controller] %>" data-action="<%= params[:action] %>"
data-resource="<%= params[:resource] %>"
data-current-user="<%= current_user.try(:encrypted_id) %>">
<body class="app-background" data-controller="<%= params[:controller] %>" data-action="<%= params[:action] %>">
<div class="wrapper">
<!-- Messages -->

View File

@ -1,37 +1,14 @@
<div class="room-section pb-2 pt-9">
<div class="container text-center">
<div class="room-section">
<div class="d-flex align-items-center" style="height: 100%;">
<div class="container text-center">
<h1 id="main-text" class="font-weight-400 resp-header">Welcome to BigBlueButton.</h1>
<h4 class="text-muted">A simple front end for your BigBlueButton Open Source Web Conferencing Server.</h4>
<h1 id="main-text" class="display-3 font-weight-400">Welcome to BigBlueButton.</h1>
<h4 class="text-muted">A simple front end for your BigBlueButton Open Source Web Conferencing Server.</h4>
<%= link_to "https://www.youtube.com/watch?v=yGX3JCv7OVM&feature=youtu.be", class: "p-3", target: "_blank" do %>
<h4>Watch a tutorial on using Greenlight <i class="fe fe-play-circle"></i></h4>
<% end %>
<%= link_to "https://www.youtube.com/watch?v=yGX3JCv7OVM&feature=youtu.be", class: "p-3", target: "_blank" do %>
<h4>Watch a tutorial on using Greenlight <i class="fe fe-play-circle"></i></h4>
<% end %>
</div>
</div>
</div>
<%= render "shared/features" %>
<script>
/*
textOptions = [
"Start your own Meeting.",
"Collaborate with Friends.",
"Connect in Real-Time.",
"Teach Students Online.",
]
textOpt = 0
var changeText = function(){
$('#main-text').text(textOptions[textOpt]);
$('#main-text').fadeIn(1000)
textOpt++;
if (textOpt > textOptions.length) { textOpt = 0; }
}
setInterval(function(){
$('#main-text').fadeOut(1000, changeText)
}, 7000);
*/
</script>

View File

@ -6,29 +6,26 @@
<h4 class="mt-2">Create an Account</h4>
</div>
<div class="card-body">
<%= form_for @user, method: :post do |f| %>
<%= form_for @user, url: create_user_path, method: :post do |f| %>
<div class="form-group">
<%= f.label "Fullname", class: "form-label" %>
<div class="input-icon">
<span class="input-icon-addon">
<i class="fas fa-user"></i>
</span>
<%= f.text_field :name, class: "form-control", placeholder: "Fullname" %>
</div>
<br>
<%= f.text_field :name, class: "form-control #{form_is_invalid?(@user, :name)}", placeholder: "Fullname" %>
<div class="invalid-feedback d-block"><%= @user.errors.full_messages_for(:name).first %></div>
</div>
<div class="form-group">
<%= f.label "Email", class: "form-label" %>
<div class="input-icon">
<span class="input-icon-addon">
<i class="fas fa-at"></i>
</span>
<%= f.text_field :email, class: "form-control", placeholder: "Email" %>
</div>
<br>
<%= f.text_field :email, class: "form-control #{form_is_invalid?(@user, :email)}", placeholder: "Email" %>
<div class="invalid-feedback d-block"><%= @user.errors.full_messages_for(:email).first %></div>
</div>
<div class="form-group">
<%= f.label "Password", class: "form-label" %>
<%= f.password_field :password, class: "form-control", placeholder: "Password" %>
<br>
<%= f.password_field :password, class: "form-control #{form_is_invalid?(@user, :password)}", placeholder: "Password" %>
<div class="invalid-feedback d-block"><%= @user.errors.full_messages_for(:password).first %></div>
</div>
<div class="form-group">
<%= 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" %>
<div class="invalid-feedback d-block"><%= @user.errors.full_messages_for(:password_confirmation).first %></div>
</div>
<div class="card-footer">
<%= f.submit "Sign up", class: "btn btn-primary float-right" %>

View File

@ -18,8 +18,8 @@ Rails.application.routes.draw do
end
# User resources.
resources :users, only: [:create], param: :user_uid
get '/signup', to: 'users#new', as: :signup
post '/signup', to: 'users#create', as: :create_user
get '/users/:user_uid/edit', to: 'users#edit', as: :edit_user
patch '/users/:user_uid/edit', to: 'users#update', as: :update_user