-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from lao9/user-menu
User Menu and Authentication
- Loading branch information
Showing
20 changed files
with
477 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
class ApplicationController < ActionController::Base | ||
protect_from_forgery with: :exception | ||
|
||
helper_method :current_user | ||
|
||
def authenticate_user | ||
unless current_user | ||
flash[:alert] = "Please login to continue!" | ||
redirect_to login_path | ||
end | ||
end | ||
|
||
def current_user | ||
@user ||= User.find(session[:user_id]) if session[:user_id] | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class SessionsController < ApplicationController | ||
|
||
def new | ||
end | ||
|
||
def create | ||
user = User.find_by(email: params[:session][:email]) | ||
if user && user.authenticate(params[:session][:password]) | ||
session[:user_id] = user.id | ||
flash[:notice] = "Welcome!" | ||
redirect_to bracks_path | ||
else | ||
flash[:error] = "Invalid Username or Password!" | ||
redirect_to login_path | ||
end | ||
end | ||
|
||
def destroy | ||
session.clear | ||
flash[:notice] = "Goodbye!" | ||
redirect_to bracks_path | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class UsersController < ApplicationController | ||
|
||
def new | ||
@user = User.new | ||
end | ||
|
||
def create | ||
@user = User.new(user_params) | ||
error_messages = @user.check_user_errors(check_user_params) | ||
if error_messages.empty? | ||
@user.save | ||
session[:user_id] = @user.id | ||
flash[:notice] = "Welcome!" | ||
redirect_to bracks_path | ||
else | ||
flash[:error] = error_messages | ||
redirect_to new_user_path | ||
end | ||
end | ||
|
||
private | ||
|
||
def check_user_params | ||
user_params.merge!({pass_confirm: params[:user][:password_confirmation]}) | ||
end | ||
|
||
def user_params | ||
params.require(:user).permit(:email, :password) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<h1>Login</h1> | ||
|
||
<div class="well"> | ||
<%= form_for :session, url: login_path do |f| %> | ||
<div class="form-group"> | ||
<%= f.label :email %> | ||
<%= f.text_field :email, class: 'form-control' %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.label :password %> | ||
<%= f.password_field :password, class: 'form-control' %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.submit "Log In", class: 'btn btn-primary' %> | ||
</div> | ||
<% end %> | ||
<h5>Don't have an account? <%= link_to "Sign up by clicking here!", new_user_path %></h5> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<h1>Sign Up</h1> | ||
|
||
<div class="well"> | ||
<%= form_for @user do |f| %> | ||
|
||
<div class="form-group"> | ||
<%= f.label :first_name %> | ||
<%= f.text_field :first_name, class: 'form-control' %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.label :last_name %> | ||
<%= f.text_field :last_name, class: 'form-control' %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.label :email %> | ||
<%= f.text_field :email, class: 'form-control' %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.label :organization %> | ||
<%= f.text_field :organization, class: 'form-control' %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.label :password %> | ||
<%= f.password_field :password, class: 'form-control' %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.label :password_confirmation %> | ||
<%= f.password_field :password_confirmation, class: 'form-control' %> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.submit "Sign Up", class: 'btn btn-primary' %> | ||
</div> | ||
<% end %> | ||
<h5>Already have an account? <%= link_to "Log in by clicking here!", login_path %></h5> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...est-0782e1429fdcee38fc05d7171a511ca3.json → ...est-876c9682ddb7320de03a2633a7304c8b.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"files":{"b-icon-7f9780781c9d08b1b924f1036e54c13fb38c190fbf27dd58a55e502d699481be.png":{"logical_path":"b-icon.png","mtime":"2017-07-31T10:36:11-06:00","size":4314,"digest":"7f9780781c9d08b1b924f1036e54c13fb38c190fbf27dd58a55e502d699481be","integrity":"sha256-f5eAeBydCLG5JPEDblTBP7OMGQ+/J91YpV5QLWmUgb4="},"spinner-47c716a105894b5888f62cfa3108a66830f958e41247c4396d70a57821464ffa.gif":{"logical_path":"spinner.gif","mtime":"2017-07-26T21:37:28-06:00","size":265881,"digest":"47c716a105894b5888f62cfa3108a66830f958e41247c4396d70a57821464ffa","integrity":"sha256-R8cWoQWJS1iI9iz6MQimaDD5WOQSR8Q5bXCleCFGT/o="},"application-cebee81d3f4145cd6b4ebaf87d6053343053e68cec726ac7f1429d61ea40ad0b.js":{"logical_path":"application.js","mtime":"2017-08-01T09:00:27-06:00","size":447267,"digest":"cebee81d3f4145cd6b4ebaf87d6053343053e68cec726ac7f1429d61ea40ad0b","integrity":"sha256-zr7oHT9BRc1rTrr4fWBTNDBT5ozscmrH8UKdYepArQs="},"application-02c40a133c96dd469be010cef633fe8413d58baaf4d673acd91f08ec92241677.css":{"logical_path":"application.css","mtime":"2017-08-01T08:59:11-06:00","size":121316,"digest":"02c40a133c96dd469be010cef633fe8413d58baaf4d673acd91f08ec92241677","integrity":"sha256-AsQKEzyW3Uab4BDO9jP+hBPVi6r01nOs2R8I7JIkFnc="},"glyphicons-halflings-regular-13634da87d9e23f8c3ed9108ce1724d183a39ad072e73e1b3d8cbf646d2d0407.eot":{"logical_path":"glyphicons-halflings-regular.eot","mtime":"2017-05-09T13:33:22-06:00","size":20127,"digest":"13634da87d9e23f8c3ed9108ce1724d183a39ad072e73e1b3d8cbf646d2d0407","integrity":"sha256-E2NNqH2eI/jD7ZEIzhck0YOjmtBy5z4bPYy/ZG0tBAc="},"glyphicons-halflings-regular-a26394f7ede100ca118eff2eda08596275a9839b959c226e15439557a5a80742.woff":{"logical_path":"glyphicons-halflings-regular.woff","mtime":"2017-05-09T13:33:22-06:00","size":23424,"digest":"a26394f7ede100ca118eff2eda08596275a9839b959c226e15439557a5a80742","integrity":"sha256-omOU9+3hAMoRjv8u2ghZYnWpg5uVnCJuFUOVV6WoB0I="},"glyphicons-halflings-regular-e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456.ttf":{"logical_path":"glyphicons-halflings-regular.ttf","mtime":"2017-05-09T13:33:22-06:00","size":45404,"digest":"e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456","integrity":"sha256-45UEQJN1fYKvyxOJV9BqHqk2G9zwtELQahioBRr1dFY="},"glyphicons-halflings-regular-42f60659d265c1a3c30f9fa42abcbb56bd4a53af4d83d316d6dd7a36903c43e5.svg":{"logical_path":"glyphicons-halflings-regular.svg","mtime":"2017-05-09T13:33:22-06:00","size":108738,"digest":"42f60659d265c1a3c30f9fa42abcbb56bd4a53af4d83d316d6dd7a36903c43e5","integrity":"sha256-QvYGWdJlwaPDD5+kKry7Vr1KU69Ng9MW1t16NpA8Q+U="}},"assets":{"b-icon.png":"b-icon-7f9780781c9d08b1b924f1036e54c13fb38c190fbf27dd58a55e502d699481be.png","spinner.gif":"spinner-47c716a105894b5888f62cfa3108a66830f958e41247c4396d70a57821464ffa.gif","application.js":"application-cebee81d3f4145cd6b4ebaf87d6053343053e68cec726ac7f1429d61ea40ad0b.js","application.css":"application-02c40a133c96dd469be010cef633fe8413d58baaf4d673acd91f08ec92241677.css","glyphicons-halflings-regular.eot":"glyphicons-halflings-regular-13634da87d9e23f8c3ed9108ce1724d183a39ad072e73e1b3d8cbf646d2d0407.eot","glyphicons-halflings-regular.woff":"glyphicons-halflings-regular-a26394f7ede100ca118eff2eda08596275a9839b959c226e15439557a5a80742.woff","glyphicons-halflings-regular.ttf":"glyphicons-halflings-regular-e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456.ttf","glyphicons-halflings-regular.svg":"glyphicons-halflings-regular-42f60659d265c1a3c30f9fa42abcbb56bd4a53af4d83d316d6dd7a36903c43e5.svg"}} | ||
{"files":{"b-icon-7f9780781c9d08b1b924f1036e54c13fb38c190fbf27dd58a55e502d699481be.png":{"logical_path":"b-icon.png","mtime":"2017-07-31T10:36:11-06:00","size":4314,"digest":"7f9780781c9d08b1b924f1036e54c13fb38c190fbf27dd58a55e502d699481be","integrity":"sha256-f5eAeBydCLG5JPEDblTBP7OMGQ+/J91YpV5QLWmUgb4="},"spinner-47c716a105894b5888f62cfa3108a66830f958e41247c4396d70a57821464ffa.gif":{"logical_path":"spinner.gif","mtime":"2017-07-26T21:37:28-06:00","size":265881,"digest":"47c716a105894b5888f62cfa3108a66830f958e41247c4396d70a57821464ffa","integrity":"sha256-R8cWoQWJS1iI9iz6MQimaDD5WOQSR8Q5bXCleCFGT/o="},"application-de129d5c3cf0bdda56c0144f00d4cbfe4870cedd9237b588cfd06c45cea319ab.js":{"logical_path":"application.js","mtime":"2017-08-01T12:01:25-06:00","size":447492,"digest":"de129d5c3cf0bdda56c0144f00d4cbfe4870cedd9237b588cfd06c45cea319ab","integrity":"sha256-3hKdXDzwvdpWwBRPANTL/khwzt2SN7WIz9BsRc6jGas="},"application-02c40a133c96dd469be010cef633fe8413d58baaf4d673acd91f08ec92241677.css":{"logical_path":"application.css","mtime":"2017-08-01T08:59:11-06:00","size":121316,"digest":"02c40a133c96dd469be010cef633fe8413d58baaf4d673acd91f08ec92241677","integrity":"sha256-AsQKEzyW3Uab4BDO9jP+hBPVi6r01nOs2R8I7JIkFnc="},"glyphicons-halflings-regular-13634da87d9e23f8c3ed9108ce1724d183a39ad072e73e1b3d8cbf646d2d0407.eot":{"logical_path":"glyphicons-halflings-regular.eot","mtime":"2017-05-09T13:33:22-06:00","size":20127,"digest":"13634da87d9e23f8c3ed9108ce1724d183a39ad072e73e1b3d8cbf646d2d0407","integrity":"sha256-E2NNqH2eI/jD7ZEIzhck0YOjmtBy5z4bPYy/ZG0tBAc="},"glyphicons-halflings-regular-a26394f7ede100ca118eff2eda08596275a9839b959c226e15439557a5a80742.woff":{"logical_path":"glyphicons-halflings-regular.woff","mtime":"2017-05-09T13:33:22-06:00","size":23424,"digest":"a26394f7ede100ca118eff2eda08596275a9839b959c226e15439557a5a80742","integrity":"sha256-omOU9+3hAMoRjv8u2ghZYnWpg5uVnCJuFUOVV6WoB0I="},"glyphicons-halflings-regular-e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456.ttf":{"logical_path":"glyphicons-halflings-regular.ttf","mtime":"2017-05-09T13:33:22-06:00","size":45404,"digest":"e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456","integrity":"sha256-45UEQJN1fYKvyxOJV9BqHqk2G9zwtELQahioBRr1dFY="},"glyphicons-halflings-regular-42f60659d265c1a3c30f9fa42abcbb56bd4a53af4d83d316d6dd7a36903c43e5.svg":{"logical_path":"glyphicons-halflings-regular.svg","mtime":"2017-05-09T13:33:22-06:00","size":108738,"digest":"42f60659d265c1a3c30f9fa42abcbb56bd4a53af4d83d316d6dd7a36903c43e5","integrity":"sha256-QvYGWdJlwaPDD5+kKry7Vr1KU69Ng9MW1t16NpA8Q+U="}},"assets":{"b-icon.png":"b-icon-7f9780781c9d08b1b924f1036e54c13fb38c190fbf27dd58a55e502d699481be.png","spinner.gif":"spinner-47c716a105894b5888f62cfa3108a66830f958e41247c4396d70a57821464ffa.gif","application.js":"application-de129d5c3cf0bdda56c0144f00d4cbfe4870cedd9237b588cfd06c45cea319ab.js","application.css":"application-02c40a133c96dd469be010cef633fe8413d58baaf4d673acd91f08ec92241677.css","glyphicons-halflings-regular.eot":"glyphicons-halflings-regular-13634da87d9e23f8c3ed9108ce1724d183a39ad072e73e1b3d8cbf646d2d0407.eot","glyphicons-halflings-regular.woff":"glyphicons-halflings-regular-a26394f7ede100ca118eff2eda08596275a9839b959c226e15439557a5a80742.woff","glyphicons-halflings-regular.ttf":"glyphicons-halflings-regular-e395044093757d82afcb138957d06a1ea9361bdcf0b442d06a18a8051af57456.ttf","glyphicons-halflings-regular.svg":"glyphicons-halflings-regular-42f60659d265c1a3c30f9fa42abcbb56bd4a53af4d83d316d6dd7a36903c43e5.svg"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file renamed
BIN
+118 KB
...3343053e68cec726ac7f1429d61ea40ad0b.js.gz → ...bfe4870cedd9237b588cfd06c45cea319ab.js.gz
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
FactoryGirl.define do | ||
factory :user do | ||
first_name "MyString" | ||
last_name "MyString" | ||
email "MyString" | ||
password_digest "MyString" | ||
organization "MyString" | ||
first_name { Faker::Name.first_name } | ||
last_name { Faker::Name.last_name } | ||
sequence :email do |n| | ||
Faker::Internet.email("lauren#{n}") | ||
end | ||
password "password" | ||
organization "Turing School" | ||
end | ||
end |
File renamed without changes.
Oops, something went wrong.