Skip to content
Snippets Groups Projects
Commit 28c779c6 authored by Treadway, Ross T (UG - Computer Science)'s avatar Treadway, Ross T (UG - Computer Science)
Browse files

Adding Devise and Bootstrap Gems, adding user, adding the UI for Sign In, Sign...

Adding Devise and Bootstrap Gems, adding user, adding the UI for Sign In, Sign Up, Edit User, and View User
parent 840c0522
No related branches found
No related tags found
No related merge requests found
Showing
with 412 additions and 0 deletions
...@@ -27,6 +27,13 @@ gem "stimulus-rails" ...@@ -27,6 +27,13 @@ gem "stimulus-rails"
# Build JSON APIs with ease [https://github.com/rails/jbuilder] # Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder" gem "jbuilder"
gem "devise"
gem 'bootstrap', '~> 5.1.3'
gem 'jquery-rails'
gem 'turbolinks'
# Use Redis adapter to run Action Cable in production # Use Redis adapter to run Action Cable in production
# gem "redis", "~> 4.0" # gem "redis", "~> 4.0"
......
...@@ -68,9 +68,16 @@ GEM ...@@ -68,9 +68,16 @@ GEM
tzinfo (~> 2.0) tzinfo (~> 2.0)
addressable (2.8.0) addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0) public_suffix (>= 2.0.2, < 5.0)
autoprefixer-rails (10.4.2.0)
execjs (~> 2)
bcrypt (3.1.17)
bindex (0.8.1) bindex (0.8.1)
bootsnap (1.11.1) bootsnap (1.11.1)
msgpack (~> 1.2) msgpack (~> 1.2)
bootstrap (5.1.3)
autoprefixer-rails (>= 9.1.0)
popper_js (>= 2.9.3, < 3)
sassc-rails (>= 2.0.0)
builder (3.2.4) builder (3.2.4)
capybara (3.36.0) capybara (3.36.0)
addressable addressable
...@@ -87,8 +94,16 @@ GEM ...@@ -87,8 +94,16 @@ GEM
debug (1.4.0) debug (1.4.0)
irb (>= 1.3.6) irb (>= 1.3.6)
reline (>= 0.2.7) reline (>= 0.2.7)
devise (4.8.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
digest (3.1.0) digest (3.1.0)
erubi (1.10.0) erubi (1.10.0)
execjs (2.8.1)
ffi (1.15.5)
globalid (1.0.0) globalid (1.0.0)
activesupport (>= 5.0) activesupport (>= 5.0)
i18n (1.10.0) i18n (1.10.0)
...@@ -103,6 +118,10 @@ GEM ...@@ -103,6 +118,10 @@ GEM
jbuilder (2.11.5) jbuilder (2.11.5)
actionview (>= 5.0.0) actionview (>= 5.0.0)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
loofah (2.15.0) loofah (2.15.0)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
...@@ -133,6 +152,8 @@ GEM ...@@ -133,6 +152,8 @@ GEM
nio4r (2.5.8) nio4r (2.5.8)
nokogiri (1.13.3-x86_64-linux) nokogiri (1.13.3-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
orm_adapter (0.5.0)
popper_js (2.9.3)
public_suffix (4.0.6) public_suffix (4.0.6)
puma (5.6.2) puma (5.6.2)
nio4r (~> 2.0) nio4r (~> 2.0)
...@@ -170,8 +191,19 @@ GEM ...@@ -170,8 +191,19 @@ GEM
regexp_parser (2.2.1) regexp_parser (2.2.1)
reline (0.3.1) reline (0.3.1)
io-console (~> 0.5) io-console (~> 0.5)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.5) rexml (3.2.5)
rubyzip (2.3.2) rubyzip (2.3.2)
sassc (2.4.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
sprockets-rails
tilt
selenium-webdriver (4.1.0) selenium-webdriver (4.1.0)
childprocess (>= 0.5, < 5.0) childprocess (>= 0.5, < 5.0)
rexml (~> 3.2, >= 3.2.5) rexml (~> 3.2, >= 3.2.5)
...@@ -187,12 +219,18 @@ GEM ...@@ -187,12 +219,18 @@ GEM
railties (>= 6.0.0) railties (>= 6.0.0)
strscan (3.0.1) strscan (3.0.1)
thor (1.2.1) thor (1.2.1)
tilt (2.0.10)
timeout (0.2.0) timeout (0.2.0)
turbo-rails (1.0.1) turbo-rails (1.0.1)
actionpack (>= 6.0.0) actionpack (>= 6.0.0)
railties (>= 6.0.0) railties (>= 6.0.0)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (2.0.4) tzinfo (2.0.4)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.0) web-console (4.2.0)
actionview (>= 6.0.0) actionview (>= 6.0.0)
activemodel (>= 6.0.0) activemodel (>= 6.0.0)
...@@ -214,10 +252,13 @@ PLATFORMS ...@@ -214,10 +252,13 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
bootsnap bootsnap
bootstrap (~> 5.1.3)
capybara capybara
debug debug
devise
importmap-rails importmap-rails
jbuilder jbuilder
jquery-rails
mysql2 (~> 0.5.3) mysql2 (~> 0.5.3)
puma (~> 5.0) puma (~> 5.0)
rails (~> 7.0.2, >= 7.0.2.3) rails (~> 7.0.2, >= 7.0.2.3)
...@@ -225,6 +266,7 @@ DEPENDENCIES ...@@ -225,6 +266,7 @@ DEPENDENCIES
sprockets-rails sprockets-rails
stimulus-rails stimulus-rails
turbo-rails turbo-rails
turbolinks
tzinfo-data tzinfo-data
web-console web-console
webdrivers webdrivers
......
...@@ -13,3 +13,18 @@ ...@@ -13,3 +13,18 @@
*= require_tree . *= require_tree .
*= require_self *= require_self
*/ */
@import "bootstrap";
.title{
font-size: 2rem;
font-weight: 300;
}
.paragraph {
font-size: 1.5rem;
font-weight: 300;
}
.background {
background-color:aquamarine;
}
.text-box {
border-radius: 25px;
background-color: greenyellow;
margin: 20px;
padding: 20px;
}
.margin_top {
margin-top: 10px;
}
\ No newline at end of file
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
attributes = [:firstname, :lastname, :username]
devise_parameter_sanitizer.permit(:sign_up, keys: attributes)
devise_parameter_sanitizer.permit(:account_update, keys: attributes)
end
end end
class HomeController < ApplicationController
def home
end
end
\ No newline at end of file
# frozen_string_literal: true
class User::ConfirmationsController < Devise::ConfirmationsController
# GET /resource/confirmation/new
# def new
# super
# end
# POST /resource/confirmation
# def create
# super
# end
# GET /resource/confirmation?confirmation_token=abcdef
# def show
# super
# end
# protected
# The path used after resending confirmation instructions.
# def after_resending_confirmation_instructions_path_for(resource_name)
# super(resource_name)
# end
# The path used after confirmation.
# def after_confirmation_path_for(resource_name, resource)
# super(resource_name, resource)
# end
end
# frozen_string_literal: true
class User::OmniauthCallbacksController < Devise::OmniauthCallbacksController
# You should configure your model like this:
# devise :omniauthable, omniauth_providers: [:twitter]
# You should also create an action method in this controller like this:
# def twitter
# end
# More info at:
# https://github.com/heartcombo/devise#omniauth
# GET|POST /resource/auth/twitter
# def passthru
# super
# end
# GET|POST /users/auth/twitter/callback
# def failure
# super
# end
# protected
# The path used when OmniAuth fails
# def after_omniauth_failure_path_for(scope)
# super(scope)
# end
end
# frozen_string_literal: true
class User::PasswordsController < Devise::PasswordsController
# GET /resource/password/new
# def new
# super
# end
# POST /resource/password
# def create
# super
# end
# GET /resource/password/edit?reset_password_token=abcdef
# def edit
# super
# end
# PUT /resource/password
# def update
# super
# end
# protected
# def after_resetting_password_path_for(resource)
# super(resource)
# end
# The path used after sending reset password instructions
# def after_sending_reset_password_instructions_path_for(resource_name)
# super(resource_name)
# end
end
# frozen_string_literal: true
class User::RegistrationsController < Devise::RegistrationsController
before_action :configure_sign_up_params, only: [:create]
before_action :configure_account_update_params, only: [:update]
# GET /resource/sign_up
# def new
# super
# end
# POST /resource
def create
super
end
# GET /resource/edit
# def edit
# super
# end
# PUT /resource
# def update
# super
# end
# DELETE /resource
# def destroy
# super
# end
# GET /resource/cancel
# Forces the session data which is usually expired after sign
# in to be expired now. This is useful if the user wants to
# cancel oauth signing in/up in the middle of the process,
# removing all OAuth session data.
# def cancel
# super
# end
# protected
# If you have extra params to permit, append them to the sanitizer.
def configure_sign_up_params
devise_parameter_sanitizer.permit(:sign_up, keys: [:firstname, :lastname, :username])
end
# If you have extra params to permit, append them to the sanitizer.
def configure_account_update_params
devise_parameter_sanitizer.permit(:account_update, keys: [:firstname, :lastname, :username])
end
# The path used after sign up.
# def after_sign_up_path_for(resource)
# super(resource)
# end
# The path used after sign up for inactive accounts.
# def after_inactive_sign_up_path_for(resource)
# super(resource)
# end
end
# frozen_string_literal: true
class User::SessionsController < Devise::SessionsController
# before_action :configure_sign_in_params, only: [:create]
# GET /resource/sign_in
# def new
# super
# end
# POST /resource/sign_in
# def create
# super
# end
# DELETE /resource/sign_out
# def destroy
# super
# end
# protected
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_in_params
# devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
# end
end
# frozen_string_literal: true
class User::UnlocksController < Devise::UnlocksController
# GET /resource/unlock/new
# def new
# super
# end
# POST /resource/unlock
# def create
# super
# end
# GET /resource/unlock?unlock_token=abcdef
# def show
# super
# end
# protected
# The path used after sending unlock password instructions
# def after_sending_unlock_instructions_path_for(resource)
# super(resource)
# end
# The path used after unlocking the resource
# def after_unlock_path_for(resource)
# super(resource)
# end
end
class UsersController < ApplicationController
before_action :set_user, only: %i[ show edit update destroy ]
# GET /users or /users.json
def index
@users = User.all
end
# GET /users/1 or /users/1.json
def show
end
# GET /users/new
def new
@user = User.new
end
# GET /users/1/edit
def edit
end
# POST /users or /users.json
def create
@user = User.new(user_params)
respond_to do |format|
if @user.save
format.html { redirect_to user_url(@user), notice: "User was successfully created." }
format.json { render :show, status: :created, location: @user }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /users/1 or /users/1.json
def update
respond_to do |format|
if @user.update(user_params)
format.html { redirect_to user_url(@user), notice: "User was successfully updated." }
format.json { render :show, status: :ok, location: @user }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
# DELETE /users/1 or /users/1.json
def destroy
@user.destroy
respond_to do |format|
format.html { redirect_to users_url, notice: "User was successfully destroyed." }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_user
@user = User.find(params[:id])
end
# Only allow a list of trusted parameters through.
def user_params
params.require(:user).permit(:username, :firstname, :lastname, :email)
end
end
module UsersHelper
end
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
//= require jquery
//= require jquery_ujs
import "@hotwired/turbo-rails" import "@hotwired/turbo-rails"
import "controllers" import "controllers"
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
end
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
</div>
<div class="actions">
<%= f.submit "Resend confirmation instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
<p>Welcome <%= @email %>!</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
<p>Hello <%= @email %>!</p>
<% if @resource.try(:unconfirmed_email?) %>
<p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
<% else %>
<p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
<% end %>
<p>Hello <%= @resource.email %>!</p>
<p>We're contacting you to notify you that your password has been changed.</p>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment